Integer简介

Integer简介,第1张

Integer简介
//      当创建范围为[-128,127]时
Integer a = ;
Integer b = ;
Integer c = new Integer();
System.out.println("a == b :" + (a == b));
System.out.println("a == c :" + (a == c));
System.out.println();
// 当创建范围不为[-128,127]时
Integer d = ;
Integer e = ;
Integer f = new Integer();
System.out.println("d == e :" + (d == e));
System.out.println("d == f :" + (d == f));
System.out.println("d e f 互不相等(false为正确测试结果):" + (d == e || d == f || e == f));
System.out.println();
// 包装类均为值传递
Integer g = ;
Integer h = new Integer();
Test1(g);
Test2(h);
System.out.println("g = "+g);
System.out.println("h = "+h);
}
static void Test1(Integer t) {
t = ;
System.out.println("Test1内: t = " + t);
}
static void Test2(Integer t) {
t = ;
System.out.println("Test2内: t = " + t);
}
} 原文:https://blog.csdn.net/Cactus_Lrg/article/details/81489299

测试结果如下:

a == b :true
a == c :false

d == e :false
d == f :false
d e f 互不相等(false为正确测试结果):false

Test1内: t = 1
Test2内: t = 131
g = 0
h = 130

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/589447.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存