It uses equals()
to compare the data. Below is from the javadoc for Set
adds the specified element e to this set if the set contains no
element e2 such that (e==null ? e2==null : e.equals(e2)).
The equals()
method for String does a character by character comparison. From the javadoc for String
The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object