首页 > 其他 > 详细

pdd面试的一道题目-Integer

时间:2019-03-06 01:13:20      阅读:246      评论:0      收藏:0      [点我收藏+]

Integer主要考的就是IntegerCache,常量池里缓存了-128~127的值。

1.

Integer a0 = new Integer(100);

Integer a1 = new Integer(100);

Integer a2 = 100;

Integer a3 = 100;

int a4 = 100;

System.out.println(a0 == a1); //false
System.out.println(a0 == a2); //false
System.out.println(a0 == a4); //true
System.out.println(a2 == a3); //true
System.out.println(a3 == a4); //true

2. 

Integer a0 = new Integer(130);

Integer a1 = new Integer(130);

Integer a2 = 130;

Integer a3 = 130;

int a4 = 130;

System.out.println(a0 == a1); //false
System.out.println(a0 == a2); //false
System.out.println(a0 == a4); //true
System.out.println(a2 == a3); //false
System.out.println(a3 == a4); //true

 

pdd面试的一道题目-Integer

原文:https://www.cnblogs.com/CodeCafe/p/10480779.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!