ABC肯定部队,对象就不同,只用相同引用时才==位true;
equals是比较大小,故而DE对;F参数不对吧!函数原型为
boolean equals(Object obj) 参数是对象。

解决方案 »

  1.   

    在这里i,l,d都是对象,注意不是基本数据类型
    对象的比较要用equals
      

  2.   

    答案就是D,E
    谢谢Iforgot(清风雨)讲的很透彻,学习
      

  3.   

    编译结果D、E得值都为False.
    是不是都错了。
    up
      

  4.   

    stephensonlee(老实和尚) :
    是啊,我怎么也全部false了,怎么回事情,谁出来给个解释呀,学习
      

  5.   

    哈哈,就是呀!高手来看看呀~!All False!
      

  6.   

    不好意思是全错,这是Integer下的equals函数public boolean equals(Object obj)Compares this object to the specified object. The result is true if and only if the argument is not null and is an Integer object that contains the same int value as this object.
      

  7.   

    所有对象的equals都先要求参数对象类型与他相同然后比较值,这个我保证(当然是指Java本身的实现,不包括你自己重写的),大家不要因为前面说错而影响这个理解,或者大家自己看javaDoc也行。
      

  8.   

    下面是Object的该方法说明equals
    public boolean equals(Object obj)Indicates whether some other object is "equal to" this one. 
    The equals method implements an equivalence relation: It is reflexive: for any reference value x, x.equals(x) should return true. 
    It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. 
    It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. 
    It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified. 
    For any non-null reference value x, x.equals(null) should return false. 
    The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true). Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes. 
    Parameters:
    obj - the reference object with which to compare. 
    Returns:
    true if this object is the same as the obj argument; false otherwise.