Java-Object Oriented Programming
1. Basic concepts
【Object】:
- Can refer to specific things, such as Shiba Inu, Husky
- Is a concrete instance of the class
【class】:
-
Templates for instantiating objects, such as dogs
-
Abstract concept and induction of objects
-Features: static performance, such as coat color, name
-Behavior: dynamic, such as running, jumping, eating
2. Object-oriented programming: Use programming methods to reflect real-life classes and objects
Define the class in the program from the existing real class (Class)
Create (instantiate) a concrete object (Object) from a class
[Syntax for creating classes in Java]
public class 类名{
//类的内容
}
[Class naming convention]:
- Have a straightforward meaning
- Capitalize the first letter (capitalize the first letter of each word, that is, the camel-case principle);
- Don’t start with numbers, don’t include special characters
[Create an instance object of the class]
类名 对象名 = new 类名();
Dog dog1 = new Dog();
new: the most important sign for creating an instance object
Object naming rules: the same as the naming rules of class names, but the first letter is lowercase (the first letter of each word after it is uppercase)