//h1 conține studenții anului I folosind perechi număr_matricol - studentHashMap<String, Student> h1 = new HashMap<>();//h2 conține studenții anului II folosind perechi număr_matricol - studentHashMap<String, Student> h2 = new HashMap<>();//m conține studenții din fiecare an folosind perechi an_studiu – studentiHashMap<Integer, HashMap<String, Student>> m = new HashMap();h1.put("11111", new Student("Ion Popescu", 141, new int[]{10, 9, 10, 7, 8}));h1.put("22222", new Student("Anca Pop", 142, new int[]{9, 10, 10, 8}));h2.put("12121", new Student("Ana Ionescu", 241, new int[]{8, 9, 10}));h2.put("12345", new Student("Radu Mihai" , 242 , new int[]{9, 10, 8}));m.put(1, h1);m.put(2, h2);
for(Map.Entry<Integer, HashMap<String, Student>> hms : m.entrySet()) {System.out.println("An " + hms.getKey() + ": ");for(Map.Entry<String, Student> s : hms.getValue().entrySet())System.out.println(s);}