Hashtable key fetches the wrong Value
<pre><code>import java.util.*;

public class HashingTest {

 // instance variables

 String name;
 int age;
 int hashCd;
 String gender;

 public HashingTest(String nm, int age, String gend)
 {
  name = nm;
  this.age = age;
  gender = gend;
 }


 public static void main(String[] args) {

  HashingTest person1 = new HashingTest("Durvi",5,"Female");
  HashingTest person2 = new HashingTest("Pillu",5,"Female");
  HashingTest person3 = new HashingTest("Ninad",5,"Male");
  HashingTest person4 = new HashingTest("Varun",5,"Male");
  HashingTest person5 = new HashingTest("Sapna",5,"Female");
  HashingTest person6 = new HashingTest("Priya",5,"Female");

  //person2 and person1 are now referring to the same object
  person2 = person1;

  boolean truth = person1.equals(person2);

  System.out.println(truth + " : Which means that if two object varaibles are refering the same object the equals() method returns true" );

  Hashtable&lt;HashingTest, String&gt; hs = new Hashtable&lt;HashingTest, String&gt;();
  hs.put(person1, "Durvi");
  hs.put(person2, "Pillu");
  hs.put(person3, "Ninad");
  hs.put(person4, "Varun");

  String personVal = (String)hs.get(person1); 

  System.out.println(personVal);

 }
}
</code></pre>

<p>Output ::</p>

<p>true : Which means that if two object varaibles are refering the same object the equals() method returns true
Pillu</p>
