The following code throws an ArrayIndexOutOfBoundsException, because remove disturbes the iterator state. import java.util.*; public class test { public static void main(String[] args) throws Exception { IdentityHashMap m = new IdentityHashMap(); for(int i = 0; i < 10; i++) { m.put("foo" + i, "bar" + i); } Iterator iter = m.values().iterator(); while(iter.hasNext()) { System.out.println(iter.next()); iter.remove(); } } }