Get a sub list from a list

ReturnMethodSummary
List<E>subList(int fromIndex, int toIndex)Returns a view of the portion of this List between fromIndex, inclusive, and toIndex, exclusive.

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

public class Main{

  public static void main(String args[]) {

    Vector v = new Vector();

    v.add("java2s.com");
    v.add("A");
    v.add("B");
    
    List list = v.subList(0, 1);

    System.out.println(list);
  }
}

The output:


[java2s.com]
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.