Hi I have an arraylist of arraylist in this format:
[[val1, val2],[val3,val4],[val1,val2],[val1,val5]]
and would like to get the unique set of arraylists:
[[val1, val2],[val3,val4],[val1,val5]]
I have tried the following:
Set<String> uniques = new HashSet<>();
for (ArrayList<String> sublist : mappedEntities) {
uniques.addAll(sublist);
}
but this merges all the values of the internal arraylist together
Set<ArrayList<String>>instead ofSet<String>uniquesneeds to beSet<List<String>>. TheaddAllfunction takes a Collection and adds each member of the collection to the Set individually -- you just want to add the entire collection as a single item.HashSetonly contain unique values likeHashmap?ArrayList<String>are unique Objects