If x and y are String references and x == y is true, then y.equals(x)
will be true.

解决方案 »

  1.   

    如果x,y是指向String 对象的引用,并且x==y,那么y.equals(x)就等于true意思说: x==y 那么x,y必定指向同一个对象,当然y.equals(x)返回true
    String对象的equals()比较内容是否相等!
      

  2.   

    可能 由于你在类中没有 override  equal方法,导致的这样的警告错误..
      

  3.   

    这句话没错吧
    If x and y are String references,如果x,y是对象的话,并且x==y,那么x,y一定是同一个对象
    例如:
    String s=new String("abc");
    String s1=new String("abc");
    System.out.println(s==s1);
    打印为false。
    理所当然如果是同一个对象那么x.equals(y)就是true的。
      

  4.   

    这句话不是错的啊.
    ==运算符是对引用进行比较,如果两个引用指向的是同一个对象的话,结果才是true,既然是指向同一个对象,那么equals方法结果肯定为true的.楼主为什么认为这句话是错的呢?
      

  5.   

    这句话是错的,x,y是字符串的引用,x==y,只是说明他们的引用相同,从底层来看就是两个整型值相同,但并不代表他们引用的对象相同,而equals方法是比较两个对象是否相同。这一点用c语言中的指针来说明更好理解,两个指针相同,但指针指向的内容不同。
      

  6.   

    除非 x == y == null
      

  7.   

    显然不正确,在java中==比较的时reference,if x and y refer to exactly the same object(there's only one object), the x==y is true, if x and y refer to two objects with same data fields, then x==y is false,since the address of memory is different
    besides, if the object has a method equal() to compare to objects, then this method should compare the data fields of the object, not the reference
      

  8.   

    晕,这句话是说当x==y为true的时候,即两个字符串引用指向同一个字符串对象的时候,那么x.equals(y)一定为true,而不是说x==y为false的时候,x.equals(y)一定为false,既然两个引用指向同一个对象,那x.equals(y)怎么会不相等呢?