[Solved] Reworking method with stream usage [duplicate]


If you can work with a Map<String, Long> then you can use this:

public Map<String, Long> countCodingsByDate() {
    return codingHistory.historyDate.stream()
        .collect(Collectors.groupingBy(
            Function.identity(),
            Collectors.counting()
        ));
}

Note: This is the normal way to find out the occurances of a Collection. For similar questions, see: 1, 2

2

solved Reworking method with stream usage [duplicate]