Java List.remove(int index)

Syntax

List.remove(int index) has the following syntax.

E remove(int index)

Example

In the following code shows how to use List.remove(int index) method.


/*from   www  .  ja  v a  2s  .c o  m*/

import java.util.List;
import java.util.Vector;

public class Main {
  public static void main(String args[]) {
    Vector<String> v1 = new Vector<String>();
    v1.add("A");
    v1.add("B");
    v1.add("C");
    List l = v1.subList(1, 2);

    l.remove(0);

    System.out.println(l);
    System.out.println(v1);
  }
} 

The code above generates the following result.