Multiset example

Count elements in set

@Test
public void multiset_example () {

    Multiset<String> camouflage = HashMultiset.create();
    camouflage.add("Realtree APG");
    camouflage.add("Realtree Hardwoods HD");
    camouflage.add("Realtree APG");
    camouflage.add("Realtree Hardwoods Green HD");
    camouflage.add("Mossy Oak New Break-Up");
    camouflage.add("Realtree APG");

    logger.info(camouflage);

    int numberOfRealTrees = camouflage.count("Realtree APG");

    assertEquals(3, numberOfRealTrees);
}

Output

[Realtree Hardwoods Green HD, Realtree Hardwoods HD, Mossy Oak New Break-Up, Realtree APG x 3]