HashMap
public class hashmapinside {
public static void main(String[] args) {
HashMap<student,Integer> map1 = new HashMap<>();
map1.put(new student("胡博士", 19), 1);
map1.put(new student("李博士", 20), 1);
map1.put(new student("王博士", 19), 1);
HashMap<student,Integer> map2 = new HashMap<>();
map2.put(new student("张博士", 19), 2);
map2.put(new student("章博士", 20), 2);
map2.put(new student("叶博士", 19), 2);
HashMap< HashMap< student, Integer>, String> map = new HashMap<>();
map.put(map1,"java");
map.put(map2, "java");
for(HashMap<student, Integer> a : map.keySet() ){ //遍历获取外层的键
for(student b : a.keySet()){//遍历获取内层键
System.out.println(b+"班级号"+a.get(b)+"所属学科"+map.get(a));
}
}
}
}
运行结果: