当前位置:网站首页>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.
边栏推荐
- NPM ---- 安装yarn
- Kind of weird!Access the destination URL, the host can container but not
- mysql索引失效的常见9种原因详解
- DNS resolution process
- HCIP 第一天
- MySql - there is no insert, there is update or ignored
- npm、nrm两种方式查看源和切换镜像
- MySQL high-level --- storage engine, index, lock
- MySQL - Multi-table query and case detailed explanation
- HCIP BGP Comprehensive Experiment Establishing peers, route reflectors, federation, route announcement and aggregation
猜你喜欢

MySql 5.7.38下载安装教程 ,并实现在Navicat操作MySql

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

MySQL Advanced Statements (1)

物联网如何改变城市运行效率

MySql COUNT statistics function explanation

Nacos installation detailed process

MySQL Index Common Interview Questions (2022 Edition)

MarkDown公式指导手册

A detailed introduction to the deployment and usage of the Nacos registry

nodejs的安装和全局配置(超详细哦)
随机推荐
MySQL高级-MVCC(超详细整理)
Toolbox App 1.25 New Features at a Glance | Version Update
从入门到精通的MySQL数据库视频教程
npm、cnpm的安装
推出 Space On-Premises (本地部署版) Beta 版!
mysql高阶语句(一)
Different ways of shell scripting
The virtual reality real estate display system foresees the future decoration effect in advance
How the Internet of Things is changing the efficiency of city operations
MySQL高级语句(一)
MySql -- 不存在则插入,存在则更新或忽略
npm 和 yarn的区别
代码编世界 科技创未来
Xgboost报错 ValueError: Invalid shape: (1650, 2) for label
Node的安装与环境变量的配置
MySQL driver jar package download -- nanny tutorial
APP专项测试:流量测试
[OpenCV from entry to practice] image processing technology [pixel] (the most detailed in the whole network)
Write implicit join on view with jOOQ 3.14 synthetic foreign key
MySQL 5.7 installation tutorial (full-step, nanny-level tutorial)