We have a Student class as follows:
Student
class Student { private int marks; private String studentName; public int getMarks() { r
That's because of an incorrect merge function, you should instead use:
Map map = studentList.stream() .collect(Collectors.toMap( student -> student.getStudentName().toLowerCase(), Student::getMarks, (s1, s2) -> s1 + s2, // add values when merging LinkedHashMap::new));