Answer:
In Java:
import java.util.*;
public class Main{
public static void main(String[] args) {
Map<String, String> students = new HashMap<>();
students.put("STUD1", "Student 1 Name");
students.put("STUD2", "Student 2 Name");
students.put("STUD3", "Student 3 Name");
students.put("STUD4", "Student 4 Name");
for(Map.Entry m:students.entrySet()){
System.out.println(m.getKey()+" - "+m.getValue()); }
}}
Step-by-step explanation:
This creates the map named students
Map<String, String> students = new HashMap<>();
The next four lines populates the map with the ID and name of the 4 students
students.put("STUD1", "Student 1 Name");
students.put("STUD2", "Student 2 Name");
students.put("STUD3", "Student 3 Name");
students.put("STUD4", "Student 4 Name");
This iterates through the map
for(Map.Entry m:students.entrySet()){
This prints the details of each student
System.out.println(m.getKey()+" - "+m.getValue()); }