I have an ArrayList that has a nested ArrayList of Strings and I want to remove duplicates from. I know if I always wanted to remove duplicates, I shouldn’t use an ArrayList, but in some cases duplicates are valid. What is the best way to remove duplicates from the nested ArrayList?
For example, I would like to execute some Java that converts:
[[duplicate], [duplicate], [duplicate], [unique1], [unique2]]
to:
[[duplicate], [unique1], [unique2]]
What aioobe said, using a set, except you will put it in a loop since you have a two demisional array: