[Java] Map.Entry

Java 2013.11.28 14:01

for(ClassA key : myMap.keySet()) {

    System.out.println(key);

    System.out.println(myMap.get(key);

}


보다는..


for(Map.Entry<ClassA, ClassB> entrie : myMap.entrySet()) {
    System.out.println(entrie.getKey());
    System.out.println(entrie.getValue());
}

Posted by 용식
TAG ,