1import java.util.ArrayList;
2// extending class since removeRange() is a protected method
3public class ArrayListRemoveRangeMethodExample extends ArrayList<Integer>
4{
5 public static void main(String[] args)
6 {
7 ArrayListRemoveRangeMethodExample al = new ArrayListRemoveRangeMethodExample();
8 al.add(23);
9 al.add(38);
10 al.add(18);
11 al.add(62);
12 al.add(27);
13 al.add(95);
14 System.out.println("ArrayList before using removeRange method: " + al);
15 // removing range of first 2 elements
16 al.removeRange(0, 2);
17 System.out.println("ArrayList after using removeRange method: " + al);
18 }
19}