Assume I have a class called Combination that consists of two fields whoose type is a simple enum value.
Examples:
new Combination(Animal.DOG, Animal.CAT),
new Combination(Animal.CAT, Animal.APE),
new Combination(Animal.MOUSE, Animal.DOG)
I have a collection of combinations and I'd like to count the total occurences of each animal so that the example output would look like:
DOG=2
CAT=2
MOUSE=1
APE=1
I already tried different approches, but I didn't found a solution yet. Is there any simple way to do this in java 8?
Thanks in advance.
Combination?