Integer、int类型的==关系
来源:互联网 发布:java 捕获异常后抛出 编辑:程序博客网 时间:2024/06/05 20:02
public class test {
public static void main(String[] args){
int a1 = 128;
Integer a2 = 128;
// Integer a3 = 128;
Integer a4 = new Integer(128);
Integer a5 = new Integer(126);
Integer a6 = new Integer(128);
Integer a7 = 126;
Integer a8 = 126;
int a9 = 126;
Integer a10 = 128;
System.out.println("a1 == a2:"+(a1 == a2));
System.out.println("a1 == a4:"+(a1 == a4));
System.out.println("a2 == a4:"+(a2 == a4));
System.out.println("a4 == a6:"+(a4 == a6));
System.out.println("a5 == a7:"+(a5 == a7));
System.out.println("a7 == a8:"+(a7 == a8));
System.out.println("a7 == a9:"+(a7 == a9));
System.out.println("a8 == a9:"+(a8 == a9));//!!!!!!!!!!!!!Integer类型自动装箱:-128~127时,重用
System.out.println("a2 == a10:"+(a2 == a10));//!!!!!!!!!!Integer类型自动装箱:-128~127以外时,不重用
}
}
输出:
a1 == a2:true
a1 == a4:true
a2 == a4:false
a4 == a6:false
a5 == a7:false
a7 == a8:true
a7 == a9:true
a8 == a9:true
a2 == a10:false
0 0
- Integer、int类型的==关系
- int与Integer类型关系
- Integer类型与int类型的==比较
- Integer 与 int 之间的 == 关系
- Java中Integer、int、String类型之间的转换关系
- Integer类型与int的==比较
- Integer 类型与 int 的==比较
- Integer类型与int的==比较
- Integer类型与int的==比较
- Integer类型与int的==比较
- Integer 类型与 int 的==比较
- int 与 Integer 数据类型之间的关系
- Integer类型、int类型类型、String类型的相互转换
- Integer,int,==
- Integer和int类型的判断
- Integer和int类型的判断
- int 与 Integer 类型的比较
- Integer和int基本类型的比较
- Windows下Redis的安装使用
- Java之旅Struts系列(1)——Struts1(前奏)
- java中八种基本类型及默认值(2015年9月22日)
- 重启学校项目第一步。
- TableView的使用
- Integer、int类型的==关系
- hanoi问题
- ROS(Robot Operating System) 基础
- VS2013 好用的插件
- unity3d实现Loading进度条异步加载场景
- PHP实现验证码的实现
- 如何调试和分析Luci
- python随笔1: 模块的安装方式总结
- Alpha、Beta、RC、GA版本的区别