How do I remove repeated elements from ArrayList?

后端 未结 30 1773
难免孤独
难免孤独 2020-11-21 06:24

I have an ArrayList, and I want to remove repeated strings from it. How can I do this?

30条回答
  •  旧时难觅i
    2020-11-21 06:33

    As said before, you should use a class implementing the Set interface instead of List to be sure of the unicity of elements. If you have to keep the order of elements, the SortedSet interface can then be used; the TreeSet class implements that interface.

提交回复
热议问题