Java Java Maps Java Maps Java Maps Quiz

Ronald Greer
Ronald Greer
30,897 Points

Not sure why this isn't working

Im having trouble with question 3 out of 5 I've been putting "Map<String, String>" But nothing seems to be working if anyone one can tell me what I'm doing wrong that would be amazing.

1 Answer

Brad Wagner
Brad Wagner
8,750 Points

Because we are mapping Students to Grades and they have provided us with two classes named 'Student' and 'Grade' we use them as the Types for the Map. This will map 'Student' objects as the KEY and 'Grade' objects as the VALUE.

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        Map<Student,Grade> studentGradeMap = new HashMap<>(); 
    }
}

class Student {
    // omitted
}

class Grade {
    // omitted
}
Ronald Greer
Ronald Greer
30,897 Points

Thank you Brad your comment helped out a lot.