Java Object-oriented: classes, objects, references

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.