Java Collections - Map and List
In Map how do we pass a class as value. For eg- I have a Student class with two fields as name and department. Let us say I put a integer type key. Map<Integer, List<Student>> map = new HashMap<>(); The above does not give me any error but while inserting the values it shows some error, may be I'm doing it wrong. map.put(1, new Student("name", "dept")); What is the right way to insert values inside the map?