title: How does get method works in hashmap if hashcode returns a contant value and equals return false?
body: <p>I have Dept class as follows, i have overridden hashcode and equals method. Hashcode returns a constant value and equals return false always.</p>
  <pre><code>public class Dept {
      
          private int depid;
          private String deptname;
      
          public Dept(int depid, String deptname) {
              super();
              this.depid = depid;
              this.deptname = deptname;
          }
      
          public int getDepid() {
              return depid;
          }
      
          public void setDepid(int depid) {
              this.depid = depid;
          }
      
          public String getDeptname() {
              return deptname;
          }
      
          public void setDeptname(String deptname) {
              this.deptname = deptname;
          }
      
          @Override
          public int hashCode() {
      
              return 100;
          }
      
          @Override
          public boolean equals(Object obj) {
      
              return false;
          }
      
          @Override
          public String toString() {
              return &quot;Dept [depid=&quot; + depid + &quot;, deptname=&quot; + deptname + &quot;]&quot;;
          }
      }
  </code></pre>
  <p>I have a main method</p>
  <pre><code>public static void main(String[] args) {
          Dept dept = new Dept(1, &quot;it&quot;);
          Dept dept1 = new Dept(1, &quot;it&quot;);
          Dept dept2 = new Dept(1, &quot;it&quot;);
  
          HashMap&lt;Dept, String&gt; map = new HashMap&lt;&gt;();
          map.put(dept, &quot;a&quot;);
          map.put(dept1, &quot;b&quot;);
          map.put(dept2, &quot;c&quot;);
  
          System.out.println(map.get(dept2));// returns c
          System.out.println(map.get(dept1));// returns b
  }
  </code></pre>
  <p>According to the theory i have read, hashcode returning a constant value will give us the same index of bucket in hashmap hence values are stored in a single bucket
  For equals method, it is returning false and hence logically same dept object are saved multiple times.
  How is get method returning the exact correct value from hashmap?</p>