I tried to iterate over hashmap in Java, which should be a fairly easy thing to do. However, the following code gives me some problems:
HashMap hm = new HashMap(
Several problems here:
import java.util.Iterator
Map.Entry entry = (Map.Entry) iter.next();
then you need to use hm.entrySet().iterator()
, not hm.keySet().iterator()
. Either you iterate on the keys, or on the entries.