java array list remove code example
Example 1: remove item from arraylist in java
List<Integer> al = new ArrayList<>();
al.add(10);
al.add(18);
al.remove(1);
Example 2: java arraylist remove
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("item");
System.out.println(arrayList.contains("item"));
arrayList.remove("item");
Example 3: how to remove an element from an arraylist java
import java.util.List;
import java.util.ArrayList;
public class GFG
{
public static void main(String[] args)
{
List<Integer> al = new ArrayList<>();
al.add(10);
al.add(30);
al.add(1);
al.add(2);
al.remove(1);
al.remove(1);
System.out.println("Modified ArrayList : " + al);
}
}
Example 4: arraylist remove method java
public E remove(int index)