I have a College
class with nested static classes Dept
College
class College {
private String collegeName;
private Dept dept;
public Dept getDept() {
return dept;
}
public void setDept(Dept dept) {
this.dept = dept;
}
public String getCollegeName() {
return CollegeName;
}
public void setCollegeName(String collegeName) {
CollegeName = collegeName;
}
public static class Dept {
private String deptName;
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
}
}
I have list
of College
objects and trying to groupingBy
based on deptName i,e (Map<String>, List<College>)
, But no luck so far and it gives a compilation error message
List<College> list = new ArrayList<College>();
list.stream().collect(Collectors.groupingBy(College.Dept::getDeptName));
Compile Error
The method collect(Collector<? super College,A,R>) in the type Stream<College> is not applicable for the arguments (Collector<College.Dept,capture#1-of ?,Map<String,List<College.Dept>>>)