5 Replies Latest reply: Nov 5, 2006 11:37 PM by 807607 RSS

    Result of applying the boolean equals(Object) for java.lang.Object.

    807607
      Hi All,

      I m trying to learn applying the equals methods for java.lang.Object.
      Please help me with simple example


      It is reflexive: for any non-null reference value x, x.equals(x) should return true.
      Example :
      Object a=new Object();
      System.out.println(a.equals(a));//True

      It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
      Example:
      Please any body give example for this

      It is transitive: for any non-null 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.
      Example:
      Please any body give example for this


      It is consistent: for any non-null 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 objects is modified.
      Example:
      Please any body give example for this