java arraylist.remove code example
Example 1: ArrayList removeIf() method in java
import java.util.ArrayList;
public class ArrayListRemoveIfMethodExample
{
public static void main(String[] args)
{
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(15);
al.add(8);
al.add(58);
al.add(19);
al.removeIf(n -> (n % 2 == 0));
for(int a : al)
{
System.out.println(a);
}
}
}
Example 2: remove item from arraylist in java
List<Integer> al = new ArrayList<>();
al.add(10);
al.add(18);
al.remove(1);
Example 3: java arraylist remove
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("item");
System.out.println(arrayList.contains("item"));
arrayList.remove("item");