title: Can 2 different objects created in Java have same this when their hashcode is same?
body: <p>In Java, I created 2 different objects (say Person class) and I had overridden the hashCode and equals method. </p>
  
  <p>The two objects were having same hashcode and contents of them were identical.</p>
  
  <p>I displayed the this reference of the 2 objects but both the objects had same value for this. How could this be possible? </p>
  
  <p>Please explain this concept as I had thought whenever we create objects then this reference will ALWAYS be UNIQUE.</p>
  
  <p>Is that when 2 objects have SAME hashcode will this reference RETURN the same value?</p>
  
  <pre><code>import java.util.*;
  class Complex  extends Object{ 
      private double re, im;
  
      public Complex(double re, double im) {
          this.re = re;
          this.im = im;
      }  
      public void  display() {         
           String str = "Address of  object is " + this +" Hashcode is " +hashCode() +" Real " +re+" Imaginary "+im;
           System.out.println(str);
      }
      // Overriding equals method
      public boolean equals(Object o) {
  
          // If the object is compared with itself then return true  
          if (o == this) {
              return true;
          }     
  
          // typecast o to Complex so that we can compare data members 
          Complex c = (Complex) o;
  
          // Compare the data members and return accordingly 
          return Double.compare(re, c.re) == 0 &amp;&amp; Double.compare(im, c.im) == 0;
      }
      public int hashCode() {
          return Objects.hash(im,re);
      }
  }
  
  // Driver class to test the Complex class
  public class ComplexEqualsDemo {
  
      public static void main(String[] args) {
          Complex c1 = new Complex(10D, 15.01D);
          Complex c2 = new Complex(10D, 15.01D);
          c1.display();
          c2.display();
          if (c1 == c2)
              System.out.println("Equal  == operator ");
          else
              System.out.println("NOT Equal using == operator ");     
  
          if (c1.equals(c2)) {
              System.out.println("Equal - using equals method ");
          } else {
              System.out.println("Not Equal -  using equals method ");            
          }
          System.out.println("\nWatch this !!!! ");
         Complex c3 = c1;
          c1.display();
          c3.display();
          if (c1 == c3)
              System.out.println("Equal  == operator ");
          else
              System.out.println("NOT Equal using == operator ");     
  
          if (c1.equals(c3)) {
              System.out.println("Equal - using equals method ");
          } else {
              System.out.println("Not Equal -  using equals method ");            
          }
      }
  }
  </code></pre>