Without further ado, go straight to the point and follow the editor to read:
1. First convert the map object to set, and then convert it into an iterator
Iterator iterator = map.entrySet().iterator(); while(iterator.hasNext()){ Entry entry = iterator.next(); System.out.println(entry.getKey()); // Get key System.out.println(entry.getValue()); // Get value }2. First convert map to a set key value set, and then convert it into an iterator
Iterator iterator = map.keySet().iterator(); while(iterator.hasNext()){ Object key = (Object)iterator.next(); System.out.println(key); // Get key System.out.println(map.get(key)); // Get value }The above is all the content of this article. I hope that the content of this article will be of certain help to everyone’s study or work. If you have any questions, you can leave a message to communicate. At the same time, I hope to support Wulin.com more!