Package net. nie. test; import java. util. hashMap; import java. util. iterator; import java. util. map; public class HashMapTest {private static Map <Integer, String> map = new HashMap <Integer, String> ();/** 1. hashMap class ing does not guarantee the sequence; some ing can clearly ensure the sequence: TreeMap class * 2. in the process of traversing the Map, map cannot be used. put (key, newVal), map. remove (key (): * remove the element of the current iteration from the collection pointed to by the iterator * to delete the element in the access. **/Public static void main (String [] args) {map. put (1, "one"); map. put (2, "two"); map. put (3, "three"); map. put (4, "four"); map. put (5, "five"); map. put (6, "six"); map. put (7, "seven"); map. put (8, "eight"); map. put (5, "five"); map. put (9, "nine"); map. put (10, "ten"); Iterator <Map. entry <Integer, String> it = map. entrySet (). iterator (); while (it. hasNext () {Map. entry <Integer, String> entry = it. next (); int key = ent Ry. getKey (); if (key % 2 = 1) {System. out. println ("delete this:" + key + "=" + key); // map. put (key, "odd"); // ConcurrentModificationException // map. remove (key); // ConcurrentModificationException it. remove (); // OK} // traverses the current map. This new for loop cannot modify the map content because it does not pass the iterator. System. out. println ("------- nt final map element traversal:"); for (Map. entry <Integer, String> entry: map. entrySet () {int k = entry. getKey (); String v = entry. getValue (); System. out. println (k + "=" + v );}}}