Answers for "ArrayList removeRange(int fromIndex int toIndex) method in java"

1

ArrayList removeRange(int fromIndex int toIndex) method in java

import java.util.ArrayList;
// extending class since removeRange() is a protected method
public class ArrayListRemoveRangeMethodExample extends ArrayList<Integer>
{
   public static void main(String[] args)
   {
      ArrayListRemoveRangeMethodExample al = new ArrayListRemoveRangeMethodExample();
      al.add(23);
      al.add(38);
      al.add(18);
      al.add(62);
      al.add(27);
      al.add(95);
      System.out.println("ArrayList before using removeRange method: " + al);
      // removing range of first 2 elements
      al.removeRange(0, 2);
      System.out.println("ArrayList after using removeRange method: " + al);
   }
}
Posted by: Guest on October-29-2020

Code answers related to "ArrayList removeRange(int fromIndex int toIndex) method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language