六种数值包装类==比较,手动装箱与拆箱

class A{
public static void main(String args[]){
Double a = 1.0; 
Double b = 1.0;
System.out.println(a == b);//F
Float g = 1.0f;
Float h = 1.0f;

System.out.println(g == h);//F


Integer c = 1; 
Integer d = 1;
Integer c1 = 128;
Integer c2 = 128;
System.out.println(c == d);//T
System.out.println(c1 == c2);//F

Byte e = 1;
Byte f = 1;//
Long i = 1L;
Long j = 1L;
Short k = 1;
Short l = 1;
System.out.println(e == f);//T
System.out.println(i == j);//T
System.out.println(k == l);//T

Integer zz = Integer.valueOf(10);
int z = zz.intValue();
System.out.println(z==zz);//T  为啥是true?
}

}


猜你喜欢

转载自blog.csdn.net/sinat_34126677/article/details/79521749
今日推荐