Some understanding of the initialization of the "Java" object

Source: Internet
Author: User

An object creation statement

Girl y = new Girl ("Hera", 20);

It takes 8 steps to execute this sentence:

  1. New uses girl.class, so we'll find the Girl.class file and load it into memory first.

  2. If so, the static code blocks in the class are executed first, and the Girl.class class is initialized

  3. Space in heap memory, allocating a memory address

  4. Establishes the unique properties of the object in heap memory and initializes it by default. Shared properties are in the method area

  5. Initialize a property for display

  6. Executes a construction code block to construct a code block class for an object.

  7. Executes the corresponding constructor, which is the constructor class for the object.

  8. Assigning a memory address to a Y variable in stack memory

Some understanding of the initialization of the "Java" object

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.