第5章 深入理解JAVA语言 JAVA程序设计 第5章 深入理解JAVA语言----补充 5.7 相等还是不等 == 简单地说,基本类型是值相等,引用类型是引用相等 但有不少的具体情况具体分析: 基本类型 数值类型:转换后比较 浮点数,最好不直接用== Double.NAN==Double.NAN 结果为false boolean型无法与int相比较 装箱对象 注意缓存 If the value p being boxed is true, false, a byte, or a char in the range \u0000 to \u007f, or an int or short number between -128 and 127 (inclusive), then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2. Integer i = new Integer(10); Integer j = new Integer(10); System.out.println(i==j); //false,因为对象是两个 Integer m = 10; Integer n = 10; System.out.pri
原创力文档

文档评论(0)