java Classes and Objects ·

2019-05-28 13:52
categories: is an abstract concept, represents a collection of things with the same attributes and behavior.

Object: a representation of personality, each object represents a separate entity, each individual has different properties, relying on property to distinguish between different objects.

Relationship Classes and Objects: The
class is a template object, the object is an instance of a class.

Use:
(1) Formats: Declare and instantiate an object
class name of the object name = new class name ();
(2) Format II: declare the object, and then instantiate an object:
the class name of the object name = null;
object name = new class name ();
we analyzed from the perspective of memory. Firstly, the concept of two types of memory space:
(1) heap memory: save the properties of the content object. Heap memory required by the new keyword to allocate space;
(2) stack memory: save a heap memory address (here for the convenience of analysis, can be simply understood as the stack memory preservation is the name of the object)

The big difference with the reference data types that the basic data types: a reference data type requires the allocation and use of memory. So, the main function of the new keyword is to allocate memory space, that is, as long as the use of reference data types, it is necessary to use the new keyword to allocate memory space.

When an instance of the object generator, may operate as follows like manner:
Object Attribute: represents an attribute of the call in the class;.
Object Method (): representation among the calling class.

Guess you like

Origin www.cnblogs.com/jz-181007/p/10936970.html