Analyze the process of object instantiation

王林
Release: 2020-07-18 16:49:17
forward
1872 people have browsed it

Analyze the process of object instantiation

The instantiation process is divided into two steps:

(Recommended tutorial:java introductory tutorial)

First declare the object , is to open up a space in the stack, name it the name of the object, and the content inside is null;

Then use new to open up a space in the heap, the object in the heap is the object, and then put the heap The address in the space is stored in the stack, so that the object can be used, such as

A aNew=new A();
Copy after login

(Video tutorial recommendation:java video tutorial)

aNew is in the stack The name of the space, new A() is to open up space in the heap, and then assign the address in the heap to the aNew space, which is equivalent to giving the key to aNew, then aNew can operate on the space in new A() at will. , somewhat similar to pointers in C language.

The above is the detailed content of Analyze the process of object instantiation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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!