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]]
{ {1, 2}, {1, 3} }
to be collapsed to{ { 1, 2 }, { 3 } }
? or should each inner list be treated in isolation? – aioobe Mar 27 '12 at 19:20