Classes and objects
1) The concept of classes and objects? Why use classes?
2) How do I define a class?
Define a class, define a class's properties (member variables), define a method of a class (constructor method, member method)
3) if applicable object?
Class object variable =new class ();
4) Definition of the method:
Access modifier, return value type (void), method name, parameter list (formal parameter), method body
5) Method Invocation:
If the method has parameters, it is necessary to pass an argument to the method
6) Two different parameter passing methods: value passing, reference passing (array, class, interface)
Value passing: The result of an argument being changed inside a method is not preserved;
Reference passing: The result of the argument being changed in the method is reserved;
Assignment is a similar principle.
7) Issues that should be noted when using member variables and local variables.
A) The position defined is different: the member variable is defined in the class, and the local variable is defined inside the method.
b) The member variable can be preceded by an access modifier, and the local variable has no access modifier.
c) The member variable has an initial value, and the local variable has no initial value.
d) Scope of use: Member variables can be used internally by all members of the method, if allowed, externally as well; local variables can only be used inside the method that defines it.
e) If there is a member variable and a local variable with the same name, the local variable takes precedence.
f) If a method has both a member variable and a local variable, in order to differentiate, you can add this modifier to the member variable.
The parameters of the method can be considered as local variables, and the assignment requires completion of the call.
8) The use of the static keyword: You can modify the variable, you can modify the method, you can modify the code block.
A) static code block execution, executed before the construction method executes, can perform some initialization operations, such as assigning a value to a static variable.
b) The static modified variable becomes a class variable or a static variable.
c) The static modified method becomes a class method or a static method.
9) class methods, call between member methods, and class methods, member methods use member variables and class variables to be aware of issues:
A) member methods can call member methods, you can tune class methods, you can use member variables, you can use class variables
B) class methods can call class methods, cannot tune member methods, you can use class variables, you cannot use member variables
10) Overloaded Method: Method name is the same, parameter list is different, and access modifier, return value, static no relationship.
One) The use of the This keyword: you can call a member variable, call a member method, call a constructor method, call a constructor method, and only the first statement that appears in the constructor method.
12) package is divided into three steps:
A) Modify the access modifiers for member variables
b) Set Get\set
c) If there is logic control, add control
Java Object-oriented review (i) Classes and objects