Remove all occurrences of an element from ArrayList

前端 未结 5 1134
傲寒
傲寒 2021-01-31 07:00

I am using java.util.ArrayList, I want to remove all the occurrences of a particular element.

    List l = new ArrayList         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-31 07:55

    while(l.remove("first")) { }
    

    This removes all elements "first" from the list.

提交回复
热议问题