Java is based on object-oriented programming, so there is the concept of classes and objects, classes are divided into ordinary classes and abstract classes.
One. Defining classes
A class consists of N constructor member variable methods, which can be undefined, or n can be defined according to syntax.
[modifier] class name {
The constructor *n a
Member Variable *n
Method *n A
}
1. Class modifiers can only be one of public final abstract three, or not decorated, the class name is generally capitalized, and the hump is named
(i). Definition of member variables
[modifier] Data type variable name;
[modifier] Data type variable name = default value;
1. Modifier: Can not write (default) but only with public private protected one of the decoration or combination of static final one of the same line decoration
(b). Definition of a method
[modifier] Returns the Type method name (formal parameter list) {
Execution code, method body
}
1. Modifier. Can not write (default) but only with one of the public private protected or the combination of one of the abstract final is modified by the line or add static combination decoration
Abstract methods of abstract classes cannot use static adornments
(iii). Constructor definition
[Modifier] class name (formal parameter list) {
Constructor Execution body
}
1. Modifier can not write (default) but can only be decorated with one of public private protected
(iv). About static
The simple method of static modification or the member variable belongs to this class, and the class or object under the class can be used;
The static modifier is actually used to distinguish whether a method or variable is a class or an object. (The current summary of the study may vary)
Two objects, references, pointers
1.java creates an object such as Object Obj=new object ();
This code actually produces 2 things an obj variable an object object
and point the Obj object to the memory address of the object.
If the object is assigned to another variable, Java does not regenerate the memory block, but instead directly directs the object's address to the change amount.
So no matter how many variables are assigned to the object, the address is only directed to the variable.
A variable that changes a value of object to all variables of that object, and is changed when used, because it points to the same address
Java definition Class object, reference, pointer