Removing duplicate elements from a List

后端 未结 8 1596
忘掉有多难
忘掉有多难 2020-12-01 17:17

I have developed an array list.

ArrayList list = new ArrayList();

list.add(\"1\");
list.add(\"2\");
list.add(\"3\");
list.add(\"         


        
8条回答
  •  执念已碎
    2020-12-01 18:04

    You can use a set in the first place or convert into it:

     Set set = new TreeSet(list);
    

提交回复
热议问题