I have the same question as you. But after googling, I figure it out. It is related to the characteristic of ArrayList and Set in Java.
Here is JavaDocs that I quote:
This class implements the Set interface, backed by a hash table (actually a HashMap instance).
Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.
Combing (1) and (2), Set uses hashtable which relies on hashCode() and equals() method of the E(element in Set). For ArrayList, hashCode() and equals() are based on deep equals. Thus, it is right to use HashSet here to avoid duplicates of Arraylist.
More info, please refer to [this post].(https://stackoverflow.com/questions/1075656/simple-way-to-find-if-two-different-lists-contain-exactly-the-same-elements)