Stored procedures in memory for Java member variables

Source: Internet
Author: User

The running result of the above code:

1). First look at the third line:

Person P01 = new person ();

The left side of the equals sign creates a variable "P01" of Class "person" (Creates a "P01" in the Memory stack space):

The right side of the equals sign creates an area in the heap space to hold the "P01" and passes the address to "P01":

The initial value of the member variable in the current class is the default value: 1. The default value for the Byte/short/long/int type is "0"; 2. The default value for char type is "space";

The default value for the 3.boolean type is "false"; 4. The default value for a reference type is "null";

2). So the fourth to fifth line of code output is the default value

3). Line sixth outputs the address of the P01 object.

4). Line seventh through line nineth to assign values to three member variables

5). line 12th through 13th output new assignment Age name gender

6). Line 14th outputs the same address as the sixth line, stating that the address does not change with the assignment

Stored procedures in memory for Java member variables

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.