当前位置:网站首页>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.
边栏推荐
- MySql 5.7.38 download and installation tutorial, and realize the operation of MySql in Navicat
- 股价屡创新低 地产SaaS巨头陷入困境 明源云该如何转型自救?
- APP专项测试:流量测试
- oracle 远程连接数据库
- Analysis of port 9848 error at startup of Nacos client (non-version upgrade problem)
- 推出 Space On-Premises (本地部署版) Beta 版!
- An advanced method for solving palindromes
- Different ways of shell scripting
- MySQL高级语句(一)
- MySQL union query (multi-table query)
猜你喜欢
MySQL Advanced - MVCC (ultra-detailed finishing)
Leetcode周赛304
Nacos installation configuration and single-machine deployment tutorial
APP special test: traffic test
selenium + robotframework的运行原理
Leetcode parentheses matching problem -- 32. The longest parentheses effectively
The advantages of making web3d dynamic product display
Ant three sides: MQ message loss, duplication, backlog problem, what are the solutions?
MySQL高级SQL语句
mysql高阶语句(一)
随机推荐
MySQL索引常见面试题(2022版)
leetcode-338.比特位计数
Xgboost报错 ValueError: Invalid shape: (1650, 2) for label
MySQL高级SQL语句
c语言指针运算
使用jOOQ 3.14合成外键在视图上写隐式连接
How to perform concurrent calculation (stability test and stress test)?
rhce homework
Analysis of the source code of the JS UI framework of Hongmeng system
DNS resolution process
推出 Space On-Premises (本地部署版) Beta 版!
NPM 安装指定版本包的方法及版本号查看
MySQL union query (multi-table query)
APT + Transform to realize multi module Application distributed Application life cycle
Nacos安装详细过程
人工神经网络
APP专项测试:流量测试
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?
MySQL经典50道练习题及全网最详细解析
金蝶国际:半年亏掉去年一年,疯狂烧钱的商业模式如何持续