(1) This: is the corresponding reference of the current class. In simple terms, it represents an object of the current class.
This scenario: Resolves a local variable hidden member variable.
(2) Construction method:
Function: Initializes the data for the object.
Format: 1. The method name is the same as the class name; 2. No return value type, not even void; 3. No specific return value.
Class Student () {
Public Student () {
System.out.println ("This is the construction method");
}
Note: If we do not give a construction method, the system will automatically provide a non-parametric construction method.
Student s = new Student (); What does it do in memory:
A: Load the Student.class file into memory;
B: In the stack memory to the s variable to open up a space;
C: In the memory for the student object to apply for a space;
D: Default initialization of member variables;
E: Display initialization of the member variables;
F: Initialize the member variables by constructing the method;
G: Data initialization is complete, then the address value of the heap memory is assigned to the stack memory s variable.
(3) Static: static.
Features: (It can modify member variables and can also modify member methods)
A: Loads as the class loads.
B: Precedence over object existence.
C: Shared by class on all objects.
D: Can be called by object name, or by class name.
(4) Private:
A: Private meaning, can modify member variable and member method
B: Features: Members who have been modified by private can only be accessed in this class
Application of C:private:
To write a class later:
Give all the member variables to private.
provides the corresponding getxxx ()/setxxx () method
(5) The Main method is static:
Public: Maximum Permissions
Static: Do not create object calls
void: Return value does not make sense to the JVM
Main: is a common name.
String[] args: Can receive data, flexibility of the provider
Format: Java maindemo Hello World Java
Java Maindemo 10 20 30
Day seventh (object-oriented)