0
我得到了需要分組的對象數組列表。數組包含不同類型的對象。 下面是一個例子:按分組列表排列
List<Object[]> resultList = query.getResultList(); // call to DB
// Let's say the object array contains objects of type Student and Book
// and Student has a property Course.
// Now I want to group this list by Student.getCourse()
Map<String, Object[]> resultMap = resultList.stream().collect(Collectors.groupingBy(???));
我怎麼提供給Collectors.groupingBy()
方法? Student對象位於對象數組中的索引0處。