当前位置:网站首页>In-depth analysis of the initialization of member variables and local variables
In-depth analysis of the initialization of member variables and local variables
2022-08-02 06:58:00 【work hard and work hard c.】
1. Member variables
Member variables can be initialized without explicit initialization, because the virtual machine assigns a default value to it.
Because the member variables are part of the instance object, and all the instance objects are allocated in the heap memory, when the storage space is allocated in the virtual machine, the member variables of the memory space of the instance object are all allocated.Default initialization, so member variables have value even if you don't explicitly initialize them (the default value for primitive data types is 0, and the default value for reference data types is Null).
2. Local variables
Local variables must be initialized, otherwise they cannot be used.
First of all, local variables are located in the method, and each method is placed in the stack of the runtime data area during the execution of the JVM, and each stack stores the local variable table, operand stack, method exit, dynamic links, etc.Because the memory space required by the local variable table is fixedly allocated during compilation, before the method is called (that is, before the method is pushed onto the stack), it is necessary to determine how much variable space the method stack needs to allocate.It will not change the size of the local variable table, so it means that local variables must be initialized when they are created to determine the size of the allocated memory.
边栏推荐
- C# Coding Conventions Handbook
- npm、cnpm的安装
- 股价屡创新低 地产SaaS巨头陷入困境 明源云该如何转型自救?
- The stock price has repeatedly hit new lows, and the real estate SaaS giant is in trouble. How should Mingyuan Cloud transform and save itself?
- Double for loop case (use js jiujiu printing multiplication table)
- leetcode solves the linked list merge problem in one step
- MySQL Advanced Statements (1)
- Nacos客户端启动出现9848端口错误分析(非版本升级问题)
- 路由规划中级篇
- APP special test: traffic test
猜你喜欢

MySQL Advanced Statements (1)

ASP.NET Core Web API 幂等性

MarkDown公式指导手册

MySQL driver jar package download -- nanny tutorial

Point Density-Aware Voxels for LiDAR 3D Object Detection Paper Notes

APT + Transform 实现多模块应用Application生命周期分发

MySQL union query (multi-table query)

Technology empowers Lhasa's "lungs", Huawei helps Lalu Wetland Smart Management to protect lucid waters and lush mountains

Leading the demand and justifying the HR value - the successful launch of the "Human Resource Leading Model HRLM"

MySQL高级SQL语句
随机推荐
MySQL高级学习笔记
BGP+MPLS综合实验
Dataset:机器学习中常用数据集下载链接集合之详细攻略
How to perform concurrent calculation (stability test and stress test)?
Node installation and configuration of environment variables
MySQL - Multi-table query and case detailed explanation
APP special test: traffic test
HCIP 第三天实验
mysql高阶语句(一)
Different ways of shell scripting
C# 编码规范手册
npm、nrm两种方式查看源和切换镜像
HCIP BGP Comprehensive Experiment Establishing peers, route reflectors, federation, route announcement and aggregation
Understand C operators in one article
MySQL high-level statements (1)
MySQL 23 classic interviews hang the interviewer
Toolbox App 1.25 New Features at a Glance | Version Update
Nacos数据库配置
postgres 多个变量填充字符串,字串格式化
Analysis of port 9848 error at startup of Nacos client (non-version upgrade problem)