首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

为什么不是false和true解决方法

2012-02-01 
为什么不是false和truepublic static void main(String[] args) {// TODO Auto-generated method stubint

为什么不是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
泛型里面也会有用到,方便

热点排行