Java List remove element by index

Description

Java List remove element by index

import java.util.ArrayList;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    List<String> arrayList = new ArrayList<String>();

    arrayList.add("CSS");
    arrayList.add("HTML");
    arrayList.add("Java");
    arrayList.add("Javascript");
    arrayList.add("SQL");

    System.out.println(arrayList);
    //  w  w w.  j  a  v  a2  s.c  o m
    // remove one element from sub list
    Object obj = arrayList.remove(0);
    System.out.println(obj + " is removed");

    System.out.println(arrayList);

  }
}



PreviousNext

Related