This is the time I began to learn Java has been unable to understand a point, previously confined to a freshman to learn C + + ideas, dead and alive do not understand the concept of objects and classes. Now on the research, although these years did not knock on the Java code, but read again, found that they can also imperceptibly gradually understand.
Object: Represents an entity that can be clearly identified in the real world.
- The state of an object, also known as a feature (property) or attribute (attribute), refers to those data thresholds that have their current values.
- The behavior of an object (behavior, also known as an action) is defined by the method. One way to invoke an object is to require an object to complete an action.
- Construction method: is to construct the object. is a special method, there are three kinds of particularity:
- The construction method must have the same name as the class in which it resides.
- The construction method has no return type, even void.
- The construction method is called when an object is created using the new operator. The function of the constructor method is to initialize the object.
To allocate space in memory for a newly created object, access it by referencing the variable.
- A class is equivalent to a programmer-defined type. A class is a reference type (reference type) The following statement declares that the type of the variable mycircle is the Circle type.
- The variable mycircle can refer to a circle object. The following statement creates an object and assigns its reference to the variable mycircle.
- Mycircle = new Circle ();
- You can write a statement that includes declaring an object reference variable, creating an object, and assigning a reference to the object to the variable.
- Circle mycircle = new Circle ();
- For reference type variables, the value stored by the corresponding memory is a reference and the storage address of the object.
Java Learning Small notes-objects and classes