How to remove element from ArrayList by checking its value?

后端 未结 11 1224
一整个雨季
一整个雨季 2020-12-01 03:47

I have ArrayList, from which I want to remove an element which has particular value...

for eg.

ArrayList a=new ArrayList         


        
11条回答
  •  猫巷女王i
    2020-12-01 04:04

    One-liner (java8):

    list.removeIf(s -> s.equals("acbd")); // removes all instances, not just the 1st one
    

    (does all the iterating implicitly)

提交回复
热议问题