private void demo1() { Map<String, String> map = new HashMap<>(); map.put("MN", "Minnesota"); map.put("WI", "Wisconsin"); map.put("NY", "New York"); map.put("WA", "Washington"); String key, name; key = "WI"; name = map.get("WI"); System.out.printf("Abbrev is %s, name is %s%n", key, name); }
private void demoStudentLookup() { List<Student> students = getAllStudents(); Map<#1String,#2Student> map = new HashMap<>(); for (Student eachStudent: students)#3map.put(eachStudent.getName(), eachStudent); Student student; String key = "Foo Johnson"; student =#4map.get(key); }