当前位置:网站首页>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
边栏推荐
猜你喜欢

Indexing best practices

Activiti5.22.0 extension supports domestic databases, taking gbase database as an example

Vector to SVG method

Introduction to redis

Briefly sort out the dualpivotquicksort

关于使用hyperbeach出现/bin/sh: 1: packr2: not found的解决方案

Take you to know what Web3.0 is

Deeply understand the underlying data structure and algorithm of MySQL index

Meta Quest内容生态总监谈App Lab设计初衷

mysql出现不存在错误
随机推荐
数据库概论 - MySQL的简单介绍
768. Block II greed that can complete sorting at most
百融榕树数据分析拆解方法
Csu18m91 is used as the master controller of the intelligent scale scheme
Basic concept and essence of Architecture
次轮Okaleido Tiger即将登录Binance NFT,引发社区热议
MySQL的数据库有关操作
768. 最多能完成排序的块 II 贪心
DTS搭载全新自研内核,突破两地三中心架构的关键技术|腾讯云数据库
代码回滚,你真的理解吗?
Deployment of ruoyi's environment and operation of the system
Common weak password Encyclopedia
How can you access the domestic server and overseas server quickly with one database?
redis入门练习
复盘:图像有哪些基本属性?关于图像的知识你知道哪些?图像的参数有哪些
Characteristics and determination scheme of Worthington pectinase
Vector to SVG method
阶乘末尾0的数量
【正则】判断, 手机号,身份证号
C language force deduction question 43 string multiplication. Optimized vertical