Java basics-1. Basic syntax, java-1 basic syntax
1 variable assignment and method call 1.1 assign values to private member variables
Source: private variables cannot be directly modified. Extended Methods
1.2 call Methods
1.3 Supplement 1: transition object-Interface
2. Call Sequence
Class loading, object creation, method calling
Static à object (constructor à general method) à local variable
3. code block, 3.1 Priority
3.2 three types of code blocks
3.2.1 construct a code block
Construct a code block: Initialize all objects in a unified manner.
2: Role
1: Initialize the object. The object runs as soon as it is created and takes precedence over the constructor.
2: differences from Constructors
1: The difference between the Construction Code block and the construction function. The construction code block initializes all objects in a unified manner, and the construction function initializes the corresponding objects.
2: Construct a code block: It extracts public information from all constructor methods.
3.2.2 static code block
1. The static code block cannot exist in any method.
2 static code blocks cannot directly access static instance variables and static instance methods. They must be accessed through instance objects of the class.
View comments