当前位置:网站首页>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

图解杂项【防止丢失进行存档用的】

Status of the thread pool

p5.js实现的炫酷交互式动画js特效

How to customize sharing links in wechat for H5 web pages

一群骷髅在飞canvas动画js特效

411 stack and queue (20. valid parentheses, 1047. delete all adjacent duplicates in the string, 150. inverse Polish expression evaluation, 239. sliding window maximum, 347. the first k high-frequency

canvas掉落的小球重力js特效动画

H5网页如何在微信中自定义分享链接

3.员工的增删改查
随机推荐
How does home office manage the data center network infrastructure?
记录一下MySql update会锁定哪些范围的数据
5. dish management business development
numpy.logical_and()
Go language development environment setup +goland configuration under the latest Windows
学习使用KindEditor富文本编辑器,点击上传图片遮罩太大或白屏解决方案
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
读取csv(tsv)文件出错
Impdp leading schema message ora-31625 exception handling
YOLOv6:又快又准的目标检测框架开源啦
Network of test and development - Common Service Protocols
Uniapp implements the function of clicking to make a call
自定义kindeditor编辑器的工具栏,items即去除不必要的工具栏或者保留部分工具栏
学习使用php实现无限极评论和无限极转二级评论解决方案
leetCode-223: 矩形面积
2022全网最全最细的jmeter接口测试教程以及接口测试流程详解— JMeter测试计划元件(线程<用户>)
利用pandas读取SQL Sever数据表
oracle池式连接请求超时问题排查步骤
How large and medium-sized enterprises build their own monitoring system
包装类型与基本类型的区别