ArrayList.remove(int index) has the following syntax.
public E remove(int index)
In the following code shows how to use ArrayList.remove(int index) method.
// w w w .j a v a2 s.c o m import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<Integer> arrlist = new ArrayList<Integer> (5); arrlist.add(20); arrlist.add(15); arrlist.add(30); arrlist.add(45); System.out.println("Size of list: " + arrlist.size()); System.out.println(arrlist); arrlist.remove(2); System.out.println("Size of list: " + arrlist.size()); System.out.println(arrlist); } }
The code above generates the following result.