Nineth Chapter
Publicly public with + means that any method is accessible
Protect protected with # indicates that a class within a package or a method of a derived class that declares a protected Member's class is accessible.
Proprietary private-means that only the method of the class that declares the private member is accessible.
Package-level, or Default no representation: Package-level members can be accessed by methods of all classes within the package (friendly). Java no friend, no destructor (due to automatic garbage collection)
no return type , name of the function name, used to initialize the object.
Does not execute automatically, only when new is executed or explicitly called through super or this.
Must be an instance method that can be public, protected, private, and package-level access rights.
The variable for the class is a reference (equivalent to the C pointer) and must be instantiated with new creation and invocation of the constructor.
Circle C2=new Circle (5.0);//must have parentheses when invoked, can be initialized with a parameter
Default constructor (same as C + +)
If the class does not have any constructors defined, the compiler automatically provides a default constructor with no parameters.
If a constructor is already customized, the compiler does not provide a default constructor.
Java does not have destructors, but it automatically calls finalize () before the memory garbage is reclaimed, and can override defining the function to do what it wants (such as turning off the device)
- Static variables, constants, methods
Instance variable (instance variable): A member variable that is not decorated with static, belongs to a specific instance (object) of a class, and can be accessed only by object, such as "object name. Instance variable" or "New A (). Instance variable", "super. Instance variable", "this". Instance variable ” 。
static variables (variable) are variables modified with static, shared by all instances (objects) of a class, also known as class variables. can be accessed by object or class name, advocating "class name. Static variable" access. Each object shares a static variable.
The parent class's final instance function f prohibits subclasses from overriding the parent class F: Subclasses cannot define the same signature instance F. When an instance function of the parent class F is not final, the subclass can overwrite the parent class's F.
The constructor cannot be final .
The final static function F of the parent class prohibits the child from being similarly signed to hide the F of the parent class.
The hidden meaning can be found, overwriting means cannot be retrieved: If the reference variable refers to a subclass object, the overridden function is called by that variable, and the overridden parent class function cannot be called through.
The constructor cannot be decorated with static: The static function has nothis.
Static methods can be called by object or class name.
Static methods can access only static members of a class through an object to access instance members in the class.
Static methods do not achieve polymorphism through late binding.
The scope of member variables, including instance variables and static variables, is the entire class, regardless of the location of the declaration.
If the initialization of one member variable depends on another member variable, the latter must be declared before it
This reference: is a reference to the current object that invokes a method
You can call other constructors of the current class through this to prevent recursive calls.
This (actualparameterlistopt)//invokes the constructor of the current class
The above call must be the 1th statement of the current constructor.
Tenth Chapter
Object-oriented development: A software system consists of a series of objects that participate in the activity. Therefore, it is necessary to establish object model, dynamic model and functional model.
Object Model: Describes the organizational structure of an object. is the core model.
Dynamic model: Describes the interaction behavior between objects.
Functional Model: Describes the behavior or state change of an object.
Object model: Describes which properties constitute the object. The composing methods include: Association, aggregation, composition, dependency, inheritance.
Association Relationship (Association) is a common two-element relationship between objects that are connected through activities. For example, students (Student) course (Course), teacher (Faculty) teaches courses (Course), which can be expressed in UML.
An aggregation relationship (aggregation) is an ownership relationship that represents the relationship between the whole and the part, that is, the has-a relationship. The owner becomes the aggregate, and the subordinate object is called the aggregated person. In an aggregation relationship, an object can be owned by multiple aggregators (Weak has a).
A composition relationship (composition) is a subordinate relationship that indicates that a dependent is strongly dependent on the aggregation. A slave can only be owned by a single aggregate, and the aggregation is responsible for the creation and destruction of the dependents (Strong has a).
A dependency relationship (dependency) refers to a relationship between two classes (called a client) that is dependent on another (called a supplier). In UML, draw a dashed line with arrows from the client to point to the supplier class.
An inheritance relationship (inheritance) represents a is-a relationship between subclasses and parent classes.
An implementation relationship (realization) represents a relationship between a class and an interface. class implements the interface.
Java Fundamentals Nine or 10