filter Map in Java 8 Streams
问题 I was trying to filter Entries in HashMap using Streams API, but stuck in last method call Collectors.toMap . So, I don't have clue to implemement toMap method public void filterStudents(Map<Integer, Student> studentsMap){ HashMap<Integer, Student> filteredStudentsMap = studentsMap.entrySet().stream(). filter(s -> s.getValue().getAddress().equalsIgnoreCase("delhi")). collect(Collectors.toMap(k , v)); } public class Student { private int id; private String firstName; private String lastName;