// Example Poker:
// ArrayList of PokerCards (hand)
// -> Map with - Suit (parameter of object) as key
// - List<PokerCard> (List of objects with that parameter) as value
Map<Suit, List<PokerCard>> map = hand.stream().collect(Collectors.groupingBy(PokerCard::getSuit));
// Now you can get the number of elements for each parameter like that:
map.keySet().forEach(s -> {
System.out.println(s.name() + " " + map.get(s).size());
});