当前位置:网站首页>Difference between package type and basic type
Difference between package type and basic type
2022-06-24 10:23:00 【Ugly and ugly】
Java There is 8 Basic types of data in , Respectively :
6 Number types :byte、short、int、long, These four types are integer numbers ;float、double, These two types are floating point numbers ;
1 Kind of boolean type :boolean, namely true or false;
1 Types of characters :char.
this 8 The corresponding packaging types of the three basic types are :Byte、Short、Integer、Long、Float、Double、Boolean、Character.
Basic types | Packaging type | byte | digit | The default value is | Range |
---|---|---|---|---|---|
byte | Byte | 1 | 8 | 0 | -128~127 |
short | Short | 2 | 16 | 0 | -32768~32767 |
int | Integer | 4 | 32 | 0 | -2147483648~2147483647 |
long | Long | 8 | 64 | 0L | -9223372036854775808 ~ 9223372036854775807 |
float | Float | 4 | 32 | 0F | 1.4E-45 ~ 3.4028235E38 |
double | Double | 8 | 64 | 0D | 4.9E-324 ~ 1.7976931348623157E308 |
boolean | Boolean | 1 | 8 | false | false、true |
char | Character | 1 | 'u0000' | 0~65535 |
about boolean type , Official documents do not clearly define , It depends on JVM The specific implementation of the manufacturer . Logically, it means to occupy 1 position , But in practice, we will consider the factor of efficient computer storage . in addition ,Java The storage space occupied by each basic type of will not change with the change of machine hardware architecture like most other languages . The invariance of the amount of storage space occupied is Java One of the reasons why programs are more portable than programs written in most other languages .
in addition ,Java Use in long、float、double Type of data, it is best to add an identification after the value L、F、D perhaps l( A lowercase letter L)、f、d, Otherwise, the value will be parsed as integer data . also char Type is marked with single quotation marks , What is marked in double quotation marks is a string .
The difference between basic types and packaging types
(1) For member variables , If packing type is used , If the value is not assigned, the default value is null, There are default values for basic types
(2) The packaging type can be used for generic , And the basic type can't be .
(3) Local variables of basic data types are stored in Java In the local variables table in the virtual machine stack , Member variables of the basic data type ( Not by static
modification ) Store in Java In the heap of the virtual machine . The wrapper type belongs to the object type , Almost all object instances exist in the heap .
(4) Compared to object types , Basic data types take up very little space .
It is a common misconception that basic data types are stored in the stack . If the member variable of the basic data type is not static
Embellished words , It's in the pile . Generally speaking, it is not recommended to use static Modify member variables of basic types , The packing type corresponding to the basic data type should be used .
This article references from :Java Basic and common knowledge & Interview question summary ( On ) | JavaGuide
边栏推荐
- Role of message queuing
- Safety and food security for teachers and students of the trapped Yingxi middle school
- CVPR 2022 Oral | 英伟达提出自适应token的高效视觉Transformer网络A-ViT,不重要的token可以提前停止计算
- JMeter接口测试工具基础 — Badboy工具
- Leetcode-1089: replication zero
- CVPR 2022 oral | NVIDIA proposes an efficient visual transformer network a-vit with adaptive token. The calculation of unimportant tokens can be stopped in advance
- 学习使用php对字符串中的特殊符号进行过滤的方法
- tf. errors
- SQL sever基本数据类型详解
- 线程池的执行流程
猜你喜欢
H5网页如何在微信中自定义分享链接
一群骷髅在飞canvas动画js特效
How to standardize data center infrastructure management process
2.登陆退出功能开发
线程的 sleep() 方法与 wait() 方法的区别
整理接口性能优化技巧,干掉慢代码
Three ways to use applicationcontextinitializer
Uniapp develops wechat official account, and the drop-down box selects the first one in the list by default
canvas掉落的小球重力js特效动画
Queue queue
随机推荐
为什么 JSX 语法这么香?
卷妹带你学jdbc---2天冲刺Day1
Leetcode-498: diagonal traversal
Three ways to use applicationcontextinitializer
植物生长h5动画js特效
消息队列的作用
Getting user information for applet learning (getuserprofile and getUserInfo)
6.套餐管理业务开发
Uniapp implements the function of clicking to make a call
413-二叉树基础
Wechat applet learning to achieve list rendering and conditional rendering
numpy. logical_ and()
uniapp开发微信小程序,显示地图功能,且点击后打开高德或腾讯地图。
Normal equation
Learning to organize using kindeditor rich text editor in PHP
Troubleshooting steps for Oracle pool connection request timeout
保健品一物一码防窜货营销软件开发
分布式 | 如何与 DBLE 进行“秘密通话”
The difference between static link library and dynamic link library
4. classification management business development