I get a list of object arrays that I need to group. The arrays contain different types of objects. Here is an example:
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(???));
What do I provide to the Collectors.groupingBy()
method ?
The Student object is at index 0 in the object array.