当前位置:网站首页>Process analysis of object creation
Process analysis of object creation
2022-07-27 03:49:00 【Jiangbei - Science and technology】
Object creation process analysis
Introducing constructors
Let's take a look at a case
class Person // class Person
{
int age = 90;
String name;
Person(String n,int a) // Constructors
{
name = n; // Assign a value to a property
age = a; // ...
}
}
Person p=new Person(" Small qian ", 20);
stay JVM Memory analysis 
Process analysis ( The order must not be disordered )
- First, it will be loaded in the method area Person Class information ( Person.class), It will only load this time
- Conduct new Person(“ Small qian ”,20) Allocate space in the heap ( Address ), Create objects
- Complete object initialization
a. Default initialization age = 0 name = null
b. Explicitly initialize age = 90 name = null
c. Constructor initialization age = 20 name = Small qian - Put the address of the object in the heap , Return to P(P Is the object name , It can also be understood as a reference to an object )
Constructor not introduced
Deepen understanding and backtracking 
Code 
OK, This issue of sharing is here , Comments are welcome , Thank you for your support
边栏推荐
- 在typora中插入图片和视频
- Database usage security policy
- DTS搭载全新自研内核,突破两地三中心架构的关键技术|腾讯云数据库
- 次轮Okaleido Tiger即将登录Binance NFT,引发社区热议
- The application and significance of digital twins are the main role and conceptual value of electric power.
- LPCI-252通用型PCI接口CAN卡的功能和应用介绍
- Quick sequencing and optimization
- Network security / penetration testing tool awvs14.9 download / tutorial / installation tutorial
- Permutation and binary (Ji, DA) (day 84)
- 768. 最多能完成排序的块 II 贪心
猜你喜欢

MySQL的数据库有关操作

阿里 Seata 新版本终于解决了 TCC 模式的幂等、悬挂和空回滚问题

Use websocket to realize a web version of chat room (fishing is more hidden)

mysql底层数据结构

DTS is equipped with a new self-developed kernel, which breaks through the key technology of the three center architecture of the two places Tencent cloud database

九方智投是正规公司吗?一起聊聊九方智投

网络安全/渗透测试工具AWVS14.9下载/使用教程/安装教程

Record the problem of PHP program accessing system files incorrectly
![[tree chain dissection] template question](/img/6b/7ec6f36d5f2373aee163c2cb766b29.png)
[tree chain dissection] template question

MySQL has a nonexistent error
随机推荐
Indexing best practices
Vector to SVG method
Spark Learning Notes (V) -- spark core core programming RDD conversion operator
Member array and pointer in banyan loan C language structure
Spark Learning Notes (IV) -- spark core programming RDD
Briefly sort out the dualpivotquicksort
Add support for @data add-on in idea
unity之二维数组实现正六边形地图
Number of square arrays (day 81)
Learning and understanding of four special data types of redis
Number of 0 at the end of factorial
Basic concept and essence of Architecture
How to optimize MySQL
DNS record type and explanation of related terms
若依框架代码生成详解
Kettle读取按行分割的文件
Smart pointer shared_ ptr、unique_ ptr、weak_ ptr
Duplicate disc: what are the basic attributes of an image? What do you know about images? What are the parameters of the image
Cocos game practice-05-npc and character attack logic
The new version of Alibaba Seata finally solves the idempotence, suspension and empty rollback problems of TCC mode