I have below arrayList. I want to add student Object if studentname is same. Example if studentname is rahul I want to add 24+25. I can do it without using stream. How to do it with stream API in java 8 ? I want answer in key value pair.
Map<String, Integer> map1 = new HashMap<String, Integer>();
List<Student> arraylist = new ArrayList<Student>();
arraylist.add(new Student(223, "Chaitanya", 26));
arraylist.add(new Student(245, "Rahul", 24));
arraylist.add(new Student(246, "Rahul", 25));
Student class contains these property:
private String studentname;
private int rollno;
private int studentmarks;