日期:2014-05-20  浏览次数:20767 次

为什么不是false和true
public static void main(String[] args) {
// TODO Auto-generated method stub
int i = 1;
Integer j = new Integer(1);
System.out.print(i==j);//true
System.out.print(j.equals(i));//true
}


------解决方案--------------------
这个叫自动拆箱,楼主如果想了解更多可以去google自动装拆箱。
你程序中的 i==j 相当于 i==j.intValue()
------解决方案--------------------
autoboxing
泛型里面也会有用到,方便