当前位置:网站首页>Understanding of integer constant pool
Understanding of integer constant pool
2022-07-21 23:17:00 【Bravo!】
Method 1 saves value : use Integer Class ( Constant pool ) Buffer pool (-128-127), Exceeding the scope , A new space will be created
Integer x=21;
Integer x1=21;
System.out.println(x1==x);// Memory address comparison , return true
Integer y=133;
Integer y1=133;// Exceeded constant pool (-128~127) The scope of the
System.out.println(y1==y);// Memory address comparison , return false
Method 2 stored value : use Integer Class (-128-127)
// The created value is in the cache pool range , Then it is stored in the cache pool , More than that new New space
Integer x2=Integer.valueOf(12);
Integer x3=Integer.valueOf("12");//valueOf() It's type conversion
System.out.println(x2==x3 );// Memory address comparison
Method three save value : use Integer Construction method save value , Created a new object , So the memory addresses are different
Integer x4=new Integer(13);//Integer Integer construction method
Integer x5=new Integer("13");// String construction method ( String can only contain numbers )
System.out.println(x4==x5);// Yes new Keyword creation , So the memory addresses must not be equal
When Integer Construction method save value , Although the stored value range is within the range of the constant pool , It will also open up new memory space , Memory address must be different
边栏推荐
猜你喜欢
所有设备,全网可达
实验1-黑盒测试-软件质量保障与测试
Fiddler actual combat - small white level - installation and basic packet capturing and packet changing operations
HCIP day1
实验2-白盒测试-软件质量保障与测试
Four switches and two PCs realize network wide accessibility
Hcip day 6
MGRE comprehensive experiment
Hcip day 9
Four way ward call system
随机推荐
第五天,ospf数据包
Rip routing information protocol
【 信息搜集的内容,信息搜集的方法,信息搜集的工具,信息搜集结果的利用等】
Custom profile
Hcip:ospf section 1
Fade in and fade out of code modification model
Hcip day 11
jdbc用sql语句使用limit分页错误
Abstract abstract classes and interface interfaces
Comprehensive experiment of static routing
Day 6 area division and LSA
OSPF working process and its simple experiment
HCIP:ospf第一节
基于TCP实现客户端与服务器的图片传送
Integer常量池的理解
[contents, methods, tools and results of information collection]
The use of PageHelper is simple and popular
Rip comprehensive experiment
全网清晰虚拟机安装截图
HCIP Day1