A specific process of creating objects

A specific process of creating objects: D d = new D ();
1. When new D () operation is encountered in the code, it will first see if the D class exists in memory. If not, use the class loader to find the .class file of this class, load the content into memory (method area), and also load the dependent parent class.
2. The content of the static code block in this class will be executed when the class is loaded.
3. According to the description information of this class, apply for memory space (the size of the application is closely related to this class).
4. The space that is applied to the memory will be initialized to 0.
5. Create the parent object (execute the in-place initialization, construction block, and construction method in the parent code)
6. Continue to construct the subclass object (execute the subclass Code initialization, building blocks, construction methods)

Published 64 original articles · Likes0 · Visits 814

Guess you like

Origin blog.csdn.net/star9523/article/details/104923045