import java.util.*;
public class First {
public static void main(String[] args) {
// TODO Auto-generated method stub
HashMap<String,Integer> obj = new HashMap<String,Integer>();
obj.put("battipati", 1);
obj.put("Sai", 2);
obj.put("Nagendra", 3);
obj.put("Bhavani", 4);
obj.put("Prasad",5);
Iterator it = obj.entrySet().iterator();
while(it.hasNext()){
Map.Entry a = (Map.Entry) it.next();
System.out.println("The values are " +a);
System.out.println(a.getKey() + " = " + a.getValue());
}
}
}
public class First {
public static void main(String[] args) {
// TODO Auto-generated method stub
HashMap<String,Integer> obj = new HashMap<String,Integer>();
obj.put("battipati", 1);
obj.put("Sai", 2);
obj.put("Nagendra", 3);
obj.put("Bhavani", 4);
obj.put("Prasad",5);
Iterator it = obj.entrySet().iterator();
while(it.hasNext()){
Map.Entry a = (Map.Entry) it.next();
System.out.println("The values are " +a);
System.out.println(a.getKey() + " = " + a.getValue());
}
}
}
output:-
The values are Bhavani=4
Bhavani = 4
The values are Prasad=5
Prasad = 5
The values are battipati=1
battipati = 1
The values are Nagendra=3
Nagendra = 3
The values are Sai=2
Sai = 2
No comments:
Post a Comment