Member variables: defined in a class that describes what the object will be, can be used by methods in this class, or used by methods in other classes that are related to this class
Local variables: Defined in a method, temporarily saving data in a method, only used in the current method
Define a member variable int A, the initial value is the 0,java program assigns the initial value to the member variable and does not assign an initial value to the local variable
Local variables with the same name are not allowed in the same method, and local variables of the same name can be used in different methods
Local variables are used when the local variable and member variable have the same name according to the nearest principle
The constructor method is defined in the Java class to initialize the object's method, new+ constructs the method can create the object
The constructor method has the same name as the class, has no return value, does not write a return value type, can have parameters or no parameters, and the syntax is:
Public constructor Method name () {
}
Java Foundation II