title: how can i change the hash code of java class?
body: <p>My doubt is, i have employee class which contains two variable id and name as follows:</p>
  
  <pre><code>public class EmpBean {
    int id=10;;
    String name="uday";
  }
  </code></pre>
  
  <p>I have added this object into HashMap as follows:</p>
  
  <pre><code>HashMap&lt;EmpBean, EmpBean&gt; hashMap= new HashMap&lt;EmpBean, EmpBean&gt;();
  hashMap.put(empBean, empBean);
  </code></pre>
  
  <p>Then:<code>System.out.println(hashMap.get(empBean).id);</code></p>
  
  <blockquote>
    <p>OutPut:10;</p>
  </blockquote>
  
  <p>When i call the <code>get()</code> method of <code>hashMap</code>,it calculates the hashcode and apply hashing on that and finds the bucket and returns the value.</p>
  
  <p>so far this is fine.</p>
  
  <p>If i want to change the hash code of my object before calling the get() method.
  How can i do ?
  I tried with <code>empBean.id=2000;</code>
  But there is no change in hashcode.</p>