Object is an abstract statement. You can think of it as a representative of all instances that conform to its own definition, and instances are the actual embodiment of the object.
You can say that an instance is an object, but you cannot say that an object is an instance. Because when defining an object, you only define its own rules and logic, an instance can make itself different from other instances by inputting different data.
java related learning video recommendations: java online learning
For example: you can define a Wheel.java, which is an object; and Test.java can define two An instance of wheel.
// Wheel.java public class Wheel{ // 这个问是wheel对象 private int radius; public Wheel(){ } public Wheel(int radius){ this.radius = radius; } }
// Test.java public class Test{ Wheel wheel1 = new Wheel(3); 这个是一个Wheel实例 Wheel wheel2 = new Wheel(5); 这个是另一个Wheel实例 }
The object is an abstract statement, and the instance is the concrete manifestation. Abstract objects into classes; instantiate classes into objects.
Recommended related articles and tutorials: Zero Basic Introduction to Java
The above is the detailed content of The difference and connection between instances and objects in java. For more information, please follow other related articles on the PHP Chinese website!