I have a HashMap that contains ArrayList of subjects. Every student has different notes. How can I print those notes from the HashMap? At the end of my code I have println
, if I want to print every average specific to a subject, how can I do that?
Student student1 = new Apprentice("Jack", "Morgan");
Subject english = new Subject("English", Arrays.asList(2, 3, 2, 2));
Subject japanese = new Subject("japanese", Arrays.asList(2, 2, 2, 4));
HashMap<Student, List<Subject>> studentGrade = new HashMap<>();
studentGrade.put(student1, Arrays.asList(english, japanese));
for (Map.Entry<Apprentice, List<Subject> > entry : apprenticeGrades.entrySet()) {
System.out.println("Student " + entry.getKey());
for (Subject subject : entry.getValue()) {
System.out.println("Average from subject:" + subject.getAvg());
}