javacodex.com
Java Examples
Java Examples
memu home questions

ArrayList Remove Elements

This java example shows how to remove elements from an ArrayList.

Source: (ArrayListRemove.java)

import java.util.ArrayList;
 
public class ArrayListRemove { 
  public static void main(String[] args) { 
    ArrayList list = new ArrayList();
    list.add("John");
    list.add("Ringo");
    list.add("George");
    list.add("Paul");
    System.out.println("ArrayList Before: "+ list);
    list.remove(2);
    System.out.println("ArrayList After: "+ list);
  } 
}
 

Output:

# java ArrayListRemove 
ArrayList Before: [John, Ringo, George, Paul]
ArrayList After: [John, Ringo, Paul]

Contact: javacodex@yahoo.com