import java.util.*;
public class SetAndEntrySet {
public static void main(String[] args) {
// TODO Auto-generated method stub
TreeMap<String, Integer> lhm1 = new TreeMap<>();
lhm1.put("One", 1);
lhm1.put("Two", 2);
lhm1.put("Three", 3);
lhm1.put("Four", 4);
lhm1.put("Five", 5);
lhm1.put("Six", 6);
lhm1.put("Seven", 7);
lhm1.put("Eight", 8);
Set set = lhm1.entrySet();
Iterator itr = set.iterator();
while(itr.hasNext())
{
Map.Entry me = (Map.Entry)itr.next();
System.out.print("Key : "+me.getKey());
System.out.println(", Value : "+me.getValue());
}
}
}
No comments:
Post a Comment