MAP 활용
2011. 8. 24. 11:53ㆍ99. 정리전 - IT/11. Java
keySet을 이용
Set set = hmap.keySet();
Iterator iterator = set.iterator();
while (iterator.hasNext()) {
key = (String)iterator.next();
value = hmap.get(key);
System.out.println("key : "+key+", value : "+value);
}
Iterator iterator = set.iterator();
while (iterator.hasNext()) {
key = (String)iterator.next();
value = hmap.get(key);
System.out.println("key : "+key+", value : "+value);
}
entrySet을 이용
Set set = hmap.entrySet()
Iterator iterator = set.iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry)iterator.next();
System.out.println("key : "+entry.getKey()+", value : "+entry.getValue());
}
Iterator iterator = set.iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry)iterator.next();
System.out.println("key : "+entry.getKey()+", value : "+entry.getValue());
}