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