import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class MapOperate {
public static void main(String[] args) {
Map<String,Student> map1 =new HashMap<String,Student>();
map1.put("s1", new Student("1",99));
map1.put("s2", new Student("2",88));
map1.put("s3", new Student("3",77));
Map<String,Student> map2 =new HashMap<String,Student>();
map2.put("s4", new Student("4",99));
map2.put("s5", new Student("5",88));
map1.putAll(map2);
/*
* 1.
*/
Collection<Student> c = map1.values();
Iterator<Student> it1 = c.iterator();
while(it1.hasNext())
System.out.println(it1.next().id);
/*
* 2.
*/
Set<String> s = map1.keySet();
Iterator<String> it2 = s.iterator();
while(it2.hasNext())
System.out.println(map1.get(it2.next()).id);
}
}
class Student{
String id;
int score;
public Student(String id, int score){
this.id=id;
this.score=score;
}
}