1. Class and Object
1.1 What is an object
Overview: Everything is an object, and everything that exists objectively is an object.
1.2 What is object-oriented
Overview: Understand the detailed information of an object and pay attention to it. This process is called object-oriented.
1.3 What is a class
Class is an abstraction of things that have common attributes and behaviors in real life
Features of the class:
The class is the data type of the object
A class is a collection of objects with the same properties and behaviors
1.4 What are the properties of an object
1.5 What is the behavior of an object
Behavior: what the object can perform
1.6 The relationship between classes and objects
Class: A class is an abstract
object that has common attributes and behaviors in real life : it is a real entity that can be seen and touched.
1.7 Class definition
The importance of the class: it is the basic unit of the Java program
What is a class: It is an abstraction of things that have common attributes and behaviors in real life, and determines the attributes and behaviors that the object will have
Class composition: attributes and behavior
Attribute: Reflected by member variables in the class (variables outside the method in the class)
Behavior: Reflected in the class through member methods (compared with the previous method, remove the static keyword)
1.8 Use of category
2. Object memory graph
package javadoy5;//包名
public class doy55 {
String brand;//名字
double price;//价钱
String color;//颜色
//
public void call (String who) {
System.out.println("给"+who+"取法");
}
public void sendMessage () {
System.out.println("打电话");
}
}
package javadoy5;
public class javadoy5shoji {
public static void main(String[] args) {
doy55 one = new doy55();
System.out.println(one.brand);
System.out.println(one.price);
System.out.println(one.color);
one.brand ="华为";
one.price =8883.0;
one.color ="金色";
System.out.println(one.brand);
System.out.println(one.price);
System.out.println(one.color);
one.call("华为");
one.sendMessage();
}
}
2020080605013