ArrayList.removeRange(int fromIndex, int toIndex) has the following syntax.
protected void removeRange(int fromIndex, int toIndex)
In the following code shows how to use ArrayList.removeRange(int fromIndex, int toIndex) method.
/*w ww. j a v a 2 s.c om*/ import java.util.ArrayList; public class Main extends ArrayList<Integer>{ public static void main(String[] args) { Main arrlist = new Main(); arrlist.add(10); arrlist.add(12); arrlist.add(31); System.out.println(arrlist); // removing range of 1st 2 elements arrlist.removeRange(0,2); System.out.println(arrlist); } }
The code above generates the following result.