Five characteristics of objects
(1) Everything is an object. The object can be imagined as a new variable; it holds the data, but it can require manipulation of itself. Theoretically speaking,
All conceptual components can be presented from the problem to be solved, and then expressed as an object in the program.
(2) A program is a combination of a large set of objects; Through messaging, each object knows what to do. In order to make a request to the object, you need to
"Send a Message". More specifically, you can think of a message as a call request that calls from a sub-Lie Cheng that belongs to the target object or
Function.
(3) Each object has its own storage space, which can accommodate other objects. Alternatively, you can create new objects by encapsulating existing objects. So, despite
The concept of objects is very simple, but in the program can achieve any high complexity of the program.
(4) Each object has a type. Each object is a "instance" of a "class", according to the syntax. where "class" is "type"
The synonyms. The most important feature of a class is "what message can be sent to it"
(5) All objects of the same class can accept the same message. This is a statement that is actually not meaningful and can be understood. Because one of the types is a circle (circle)
Objects also belong to an object of type shape, so a circle can receive shape messages entirely. This means that the program code can be unified to command the "shape"
It automatically controls all objects that conform to the "shape" description, which naturally includes "circles." This feature, called the "Calling of the object", is one of the most important concepts of OOP.
。
Getting Started with Java objects