-
If a class contains properties and methods, each object of that class has its own properties, but no matter how many objects a class has, the objects share the same method
-
Summary of method parameter passing: For method parameter parameter Passing in Java, whether it is passing a native data type or a reference type, unification is a value
-
What type of reference can point to what type of object, such as a person type's application, can point to an object of type person, but cannot point to an object of type student
-
Construction method: Constructs the method to complete the initialization work of the object property, the characteristic of the construction method:
1 The name of the construction method must be exactly the same as the class name (including case)
2 constructor method does not return a value, and even void does not appear
3 If you do not construct a method for a class declaration when you define a class, the Java compiler automatically adds a constructor that has no parameters and the method body is empty for the class
Public person () {}
4 If you declare a constructor for a class when you define a class, the Java compiler will no longer add construction methods to the class
5 The constructor method of the calling class cannot be displayed, and the constructor method is usually implicitly called with the New keyword
-
The New keyword completes three things when you build the object
1 Opening up memory space for objects
2 constructor method for calling class
3 Returns the address of the generated object,
-
Default Construction Method: Constructor method has no parameters and the method body is empty
-
When using new to generate an object, the following parentheses represent the constructor's argument list, and if the constructor does not receive arguments, then it is clear that the contents of the parentheses are empty, and if the constructor receives the arguments, the actual parameters in the parentheses need to be consistent with the formal parameters in the constructor definition (the number of parameters is consistent, parameter types are consistent, each assigned value in order)