import java.util.*; public class StudentMap { public static void printMapEntries(Map map) { Set> set = map.entrySet(); Iterator> it = set.iterator(); while(it.hasNext()) { Map.Entry entry = it.next(); System.out.println(entry.getKey() + " -> "+ entry.getValue() ); } } public static void printMapValues(Map map) { Collection coll = map.values(); Iterator it = coll.iterator(); while(it.hasNext()) { System.out.println(it.next().toString()); } } public static void printMapKeys(Map map) { Set set = map.keySet(); Iterator it = set.iterator(); while(it.hasNext()) { System.out.println(it.next().toString()); } } public static void main(String args[]) { Map students = new HashMap<>(); students.put(1, new Student("John", "Smith")); students.put(2, new Student("Stanley", "Peters")); students.put(3, new Student("Edgar", "Bloch")); students.put(4, new Student("Suzan", "Miles")); students.put(5, new Student("Mary", "Poppins")); System.out.println("\nMap keys are:"); printMapKeys(students); System.out.println("\nMap values are:"); printMapValues(students); System.out.println("\nMap key-value pairs are:"); printMapEntries(students); } }