Methods of the class
Signature of method: includes access modifier, return type, method name, parameter list, return value data type
The currently learned access modifiers include: Public private protected (protected)
To pass the parameter:
1. When an argument is passed to a parameter, the data of the actual argument is copied to the formal parameter
2. Regardless of the type of actual arguments passed, the relevant formal parameters should be a copy of the data, which is the principle of value-based transfer
In 3.JAVA only a value is passed
Overload:
Method overloading when a class has two or more methods with the same name but has a different argument list
Note: Method overloads three points: different types, different quantities, different order, but not related to formal parameter names.
Constructor:
Syntax: Person someOne = new Penson ();
In-memory space can be divided into heaps, stacks, data segments, code snippets.
Advanced back-out call method structure called stack
* FIFO call method structure called Queue *
Space Division:
1. Local variables are in the stack
2. All new objects are in the heap
3. String constants are in the data segment
about the use of this:
This. refers to the properties and methods of the current object
this () refers to a constructor method that calls another constructor of this class, which is used to construct the method reuse
Note: 1. Can only be written in the construction method 2. You can only call the constructor method of this class 3. Must be written on the first line of the construction method
If the declaration of a constructor is not displayed when defining a class, the Java compiler assigns the Class A default constructor.
public classs name{
}
public car () {
}
1. Constructor does not have any return type
2. Constructor Reload:
The constructor has a different number of arguments or if the constructor has the same number of arguments, the parameter types are different.
[summary] 2016.12.1 Thursday