Person p = new Person(); What does it do in memory?

(*-*)浩
Release: 2019-11-11 14:29:06
Original
3295 people have browsed it

Person p = new Person(); What does it do in memory?

Person p = new Person();What does it do in memory?

Load the Person.class file into memory.

If p is defined in the main method, then a variable space p will be opened in the stack space.

Allocate space for objects in heap memory.

Perform default initialization of members in the object.

Perform explicit initialization of members in the object.

Call the construction code block to initialize the object. (If not, it will not be executed)

Call the constructor to initialize the object. The object is initialized.

Assign the memory address of the object to the p variable and let the p variable point to the object.

The above is the detailed content of Person p = new Person(); What does it do in memory?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!