I'm trying to find the union of two collections by using the CollectionUtils.collate method. This method comes from the package org.apache.commons.collections4
Here is the code portion :
Collection<String> tokensUnion2 = CollectionUtils.collate(
Arrays.asList(new String[]{"my", "sentence", "test", "for", "testing"}),
Arrays.asList(new String[]{"my", "sentence", "test", "is", "this"}),
false);
The result collection is the one below :
[my, sentence, test, for, test, is, testing, this]
As you can see, the resulting collection contains duplicates, even though the third parameter of CollectionUtils.collate indicates that I don't want duplicates.
Plus, the String duplicate sentence was eliminated, but the test is still there.
I could resolve this issue by simply putting the resulting collection in a HashSet, but I'd like to know what I've done wrong.
Thank you.