Fighterplane fp = new Fighterplane () first produces the object and then assigns the declaration FP
New Fighterplane ()
Produces an object based on a class template and creates a separate memory space for this object in memory.
Generating objects in a class as a template is essentially copying the attributes (domain variables) defined in the class into the object, which are defined in the class but are actually serving the object and are called object properties.
Method at the time of invocation, the system will open up a stack space for the method to hold the formal parameters and local variables in the method.
The method also accesses the domain variables copied to the object at execution time, just as the method is also copied to the object.
The stack space is freed after the execution of the method.
Although methods are defined in a class, the methods defined in a class are actually serviced for objects, and are called object methods, from the perspective that the method can access the object's domain variables.
Fighterplane FP
Produces a fighterplane declaration, at which time no objects of any class are produced, and no memory space is allocated for this class.
(Note: C + +, in C + +, an object has been produced at this time)
fp = new Fighterplane ()
Assigns the declaration FP to a specific object, and the FP becomes a reference to the object.
Java Object-oriented: classes, objects, references