Question: I have an `ArrayList<SomeObject>` in java which contains some `<SomeObject>` multiple times.
I also have a `Set<SomeObject>`, which contains some elements one time only. The elements are only uniquely distinguishable only by their name (`String SomeObject.Name`).

How am I possible to see if the list has exactly the same elements as the set, but maybe multiple times?

Thanks

Answer: 
There are several collections libraries to do this. For example commons-collection: <https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/CollectionUtils.html#isEqualCollection-java.util.Collection-java.util.Collection->

**eg. `CollectionUtils.isEqualCollection(myList, mySet)`**

If you have to write it yourself, no libraries, then just check that each contains all the elements of the other:

```
`mySet.containsAll(myList) && myList.containsAll(mySet)`

```
Create a Hash that is a String and an Integer of the count of how many time. Interate thought the list create a Hash entry and setting to one if element exists already add one to the count.

```
Hash<String, Integer> hash = new HashMap<String, Integer>();
for (String s : list) {
    if (hash.containsKey(s))
        hash.put(s, hash.get(s)++);
    else
        hash.put(s,1);
}

```