Chapter One: Abstraction and encapsulation
Class is an abstraction of an object that is an instance of a class
Second, the use of object-oriented design
The process of object-oriented design is an abstract process, which is done in three steps:
1. Find out what kind of it
2. Find out its properties
3. Find out how it behaves
Naming rules for class names, attribute names, method names, and constant names:
1. The class name consists of one or several words, with the first letter of each word capitalized, such as dog, StringBuffer
2. The attribute name and method name consist of one or more words, the first letter is lowercase, the other words are capitalized, such as Health,stuname,println (), GetMessage ().
3. The constant name consists of one or more words, all uppercase letters, such as Pi,sex_male
Four, Static constants
1.static can be used to modify properties, methods, and code blocks
2.static decorated properties and methods are called Class properties (class variables), class methods
3. Properties and methods that do not use static adornments, belong to a single object, often referred to as instance properties (instance variables), instance methods
4.static modified variables and methods can be accessed through the class name and object name, instead of static modified variables and methods can only be accessed through the object name
|
|
Static non-private decoration |
Non-static, private decoration |
|
Property |
Class properties, class variables |
Instance properties, instance variables |
|
Method |
Class method |
Instance method |
|
Calling methods |
Class name. properties
Class name. Method ()
Object. Properties
Object. Method () |
Object. Properties
Object. Method () |
|
Belong |
Class |
Single Object |
5.final can be used to modify properties, methods, and classes
6. The final modified variable becomes constant and its value is fixed
Using Java to implement object-oriented Chapter I.