Java Study Notes day08_day09 _ Object Instantiation _ private_this,
1. Classes and objects
Class is a template.
Object Instantiation is to use the new keyword to create an actual object based on the template class.
2. Define classes and create objects
Class Definition Format:
Public class name {// attribute (variable) data type variable name;... // method modifier return value type method name (parameter ){}}
Format of the created object:
Class Name object name = new Class Name ();
3. encapsulate private
Encapsulation: hides the Implementation Details of Object Attributes and methods, and only provides some public access methods.
Private: private modified members can only be accessed in the current class, but cannot be accessed directly in other classes.
4. this keyword
This keyword is a reference to this class object. this is used in the method. Which object calls this method, then this indicates that the object that calls this method references.
This function is used to distinguish member variables with the same name from local variables (this. member variables)