Class and object
- A class is a template is an abstract, an object is a concrete instance
method
- Define, call
Object reference
- In addition to the 8 types of reference types, we can all be called reference types
- Objects are manipulated by reference: stack ------ "heap (address)
Object properties
- Attributes are generally called fields, also called member variables
- Default initialization
Number 0 or 0.0
char : u0000
boolean : false
Reference type: null
Definition of attributes
Modifier attribute type attribute name = attribute value
int a = 0;
Creation and use of objects
-
The new keyword must be used to create the object, the constructor Person xiaoHuangRen = new Person();
-
The attributes of the object xiaoHuangRen.name;
xiaoHuangRen.age;
Object method xiaoHuangRen.sleep();
class
Static properties
Dynamic approach