title: Java Iteration: Hashtable vs HashMap
body: <p>Why do I get different results when I run equivalent code for hashtable and hashmaps?</p>
  
  <pre><code>Iterator&lt;Integer&gt; it = ht.keySet().iterator();
  while(it.hasNext()) {
      i = it.next();
      System.out.println(i + " : " + ht.get(i));
  }
  </code></pre>
  
  <p>ht is a hashtable object. If i replace with hm, a hashmap object, it doesn't print the values from get() method instead prints null. Why is that?</p>