当前位置:网站首页>面试:为什么整数包装类尽量用equals()来比较大小
面试:为什么整数包装类尽量用equals()来比较大小
2022-06-12 16:05:00 【眠秋雨】
Byte、Short、Integer、Long这4种类型缓存了[-128,127]的相应缓存数据。
public class Test {
public static void main(String[] args) {
Integer i1=100;
Integer i2=100;
System.out.println(i1==i2); // true
Integer i3=900;
Integer i4=900;
System.out.println(i3==i4); // false
}
}
第9行比较的其实是两对象的地址,注意这是一个坑。
边栏推荐
- Divide training set, test set and verification set
- C language partition bin file program
- [thinking about the process of structure optimization] how to build the evaluation ability of the impact of technical solutions
- CUDA out of memory or brokenpipeerror: [errno 32] broken pipe or oserror: [winerror 1455] solution to the problem that the page file is too small
- 如何使用Grafana轻松实现OVL数据可视化
- 作業提交說明 上傳作業到網盤中
- 【周赛复盘】LeetCode第80场双周赛
- Project training of Software College of Shandong University rendering engine system basic renderer (6)
- Explore the Apache shardingsphere SQL parse format function
- < 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(五)
猜你喜欢

从斐波那契数列求和想到的俗手、本手和妙手

Five models of software testing

Step by step steps to create an ABAP program with a custom screen

From K-means to capsule

redis String类型常见命令

< 山东大学软件学院项目实训 > 渲染引擎系统——辐射预计算(九)

jupyter notebook新環境快捷方式

为什么阿里巴巴不建议MySQL使用Text类型?

Project training of Software College of Shandong University rendering engine system basic renderer (6)

Project training of Software College of Shandong University rendering engine system radiation pre calculation (VIII)
随机推荐
为什么阿里巴巴不建议MySQL使用Text类型?
UDP summary (tcp/ip details volume 1/2)
Decision tree classification and examples
< 山东大学软件学院项目实训 > 渲染引擎系统——点云处理(十)
[automation] kolla Based Automated Deployment CEPH cluster
位运算例题(待续)
Project training of Software College of Shandong University rendering engine system radiation pre calculation (IX)
国产CPLD中AG1280Q48进行开发的实践之一:思路分析
Task output: dense snow ice city theme song 0612
Applet: how to get the user's mobile number in the plug-in
Analysis of China's cargo transport volume, cargo transport turnover and port cargo in 2021 [figure]
联通网管协议框图
【架构优化过程思考】如何构建技术方案影响的评估能力
Points chocolate (two points answer) Blue Bridge Cup provincial competition
(4) Googlenet replay
【工具推荐】个人本地 markdown 知识图谱软件 Obsidian
nohup 命令使用
Redis General Command
The small flying page is upgraded to be intelligent and the bug repair is faster
【周赛复盘】LeetCode第80场双周赛