How do I remove repeated elements from ArrayList?

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

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

30条回答
  •  太阳男子
    2020-11-21 06:43

    public static void main(String[] args){
        ArrayList al = new ArrayList();
        al.add("abc");
        al.add('a');
        al.add('b');
        al.add('a');
        al.add("abc");
        al.add(10.3);
        al.add('c');
        al.add(10);
        al.add("abc");
        al.add(10);
        System.out.println("Before Duplicate Remove:"+al);
        for(int i=0;i
        

    提交回复
    热议问题