public static void main(String[] args) {
HashMap<Student, String> hm1 = new HashMap<>();
hm1.put(new Student("张三",23), "上海");
hm1.put(new Student("李四",24), "北京");
HashMap<Student, String> hm2 = new HashMap<>();
hm2.put(new Student("王五",21), "郑州");
hm2.put(new Student("赵六",22), "广州");
HashMap<HashMap<Student, String>,String> hm3 = new HashMap<>();
hm3.put(hm1, "第88期");
hm3.put(hm2, "第89期");
for (HashMap<Student, String> s1 : hm3.keySet()) {
for (Student s2 : s1.keySet()) {
System.out.println(hm3.get(s1) + s1.get(s2) + s2);
}
}
}
以前自己打的,键为自定义对象, 自己添加学生对象 |