当前位置:网站首页>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.
边栏推荐
- oracle 远程连接数据库
- Machine learning -- - theory of support vector machine (SVM)
- Guarantee WIFI security in home and enterprise-with AC and AP networking experiment
- BGP+MPLS综合实验
- Xgboost报错 ValueError: Invalid shape: (1650, 2) for label
- DNS的解析流程
- C# 编码规范手册
- NPM ---- 安装yarn
- MySQL union query (multi-table query)
- Not annotated parameter overrides @NonNullApi parameter
猜你喜欢

Nodejs installation and global configuration (super detailed)

mysql高阶语句(一)

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?

MarkDown Formula Instruction Manual

触发器简单解释

MySQL driver jar package download -- nanny tutorial

HCIP 第四天

Node installation and configuration (node-v12.20.2-x64 ) and introduction to node version switching

Guarantee WIFI security in home and enterprise-with AC and AP networking experiment

Write implicit join on view with jOOQ 3.14 synthetic foreign key
随机推荐
Py之mlxtend:mlxtend库的简介、安装、使用方法之详细攻略
selenium + robotframework的运行原理
MySQL驱动jar包的下载--保姆教程
An advanced method for solving palindromes
MySQL driver jar package download -- nanny tutorial
What is the most important ability of a programmer?
Thread Basics (1)
触发器简单解释
Important concepts of target detection - IOU, receptive field, hole convolution, mAP
go里面的基本知识
Nacos installation configuration and single-machine deployment tutorial
Tips for programmers to write PPT
flex layout (flexible layout)
A list of 300+ learning resources compiled by senior engineers of the Tao Department (the latest version in 2021)
zabbix email alarm and WeChat alarm
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?
一文搞懂C操作符
Luogu mini game Daquan (everyone who uses Luogu must know)
nacos安装配置和单机部署教程
ASP.NET Core Web API 幂等性