-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIterateMap
More file actions
27 lines (24 loc) · 707 Bytes
/
Copy pathIterateMap
File metadata and controls
27 lines (24 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package collectionImpl;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class IterateHashMap
{
public static void main(String a[])
{
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("java", 26);
map.put("C++", 67);
map.put("SQL", 21);
map.put("Unix", 7);
map.put("PHP", 36);
map.put("Perl", 91);
Iterator it = map.entrySet().iterator();
while (it.hasNext())
{
Map.Entry pair = (Map.Entry)it.next();
System.out.println(pair.getKey() + " = " + pair.getValue());
it.remove(); // avoids a ConcurrentModificationException
}
}
}