import java.util.HashMap;
import java.util.Map.Entry;
public class ParameterizedType {
public static void main(String[] args) {
// 一个小学的学生, 学号对应学生
HashMap<Integer, Student> primarySchool = new HashMap<>();
primarySchool.put(1, new Student(1, "zhagnsan"));
primarySchool.put(2, new Student(2, "lisi"));
primarySchool.put(3, new Student(3, "wangwu"));
// 一个中学的学生, 学号对应学生
HashMap<Integer, Student> highSchool = new HashMap<>();
highSchool.put(1, new Student(1, "xiaocui"));
highSchool.put(2, new Student(2, "xiaoming"));
highSchool.put(3, new Student(3, "xiaohua"));
// 一个地区的学校学生, 学校名称对象学校学生
HashMap<String, HashMap<Integer, Student>> localSchool = new HashMap<>();
localSchool.put("primarySchool", primarySchool);
localSchool.put("highSchool", highSchool);
// 这个地区的学校
for (Entry<String, HashMap<Integer, Student>> schools : localSchool.entrySet()) {
// 每个学校的学生
for(Entry<Integer, Student> students : schools.getValue().entrySet()) {
System.out.println(schools.getKey() + " " + students.getKey() + " " + students.getValue().name);
}
}
}
}
class Student{
Integer id;
String name;
public Student(Integer id, String name) {
this.id = id;
this.name = name;
}
}