日期:2014-05-20 浏览次数:20999 次
public static void main(String[] args) {
int a = 10;
Integer b = new Integer(10);
System.out.println(a == b);//这里实际上是:a == b.intValue()
}
------解决方案--------------------
比较的是a和b指向的地址中的值
------解决方案--------------------
jdk1.5之后吧,基本类型的所对应的引用类型可以自动转换成基本类型与基本类型进行值比较
------解决方案--------------------
int a=10;
Integer b = new Integer(10); //这句等价于 Integer b = new Integer(a);