Java List get sub list

Description

Java List get sub list


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);
    /*from  ww w  .java  2  s  . c o  m*/
    List<String> lst = arrayList.subList(1, 3);
    for (int i = 0; i < lst.size(); i++)
      System.out.println(lst.get(i));

  }
}



PreviousNext

Related