Remove an element from specified index of ArrayList - Java Collection Framework

Java examples for Collection Framework:ArrayList

Description

Remove an element from specified index of ArrayList

Demo Code

 
import java.util.ArrayList;
 
public class Main {
 
  public static void main(String[] args) {
    ArrayList arrayList = new ArrayList();
   /*from  w w  w .  ja va  2s.com*/
    arrayList.add("1");
    arrayList.add("2");
    arrayList.add("3");
   
    Object obj = arrayList.remove(1);
    System.out.println(obj + " is removed from ArrayList");
   
    System.out.println("ArrayList contains...");
    System.out.println(arrayList);
   
  }
}

Result


Related Tutorials