LinkedList: subList(int fromIndex, int toIndex) : LinkedList « java.util « Java by API






LinkedList: subList(int fromIndex, int toIndex)

 


import java.util.LinkedList;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    LinkedList<String> lList = new LinkedList<String>();

    lList.add("1");
    lList.add("2");
    lList.add("3");
    lList.add("4");
    lList.add("5");

    System.out.println(lList);
    List lst = lList.subList(1, 4);
    System.out.println(lst);

    lst.remove(2);
    System.out.println(lst);
    System.out.println(lList);
  }
}

   
  








Related examples in the same category

1.new LinkedList < E > ()
2.LinkedList: add(E o)
3.LinkedList: add(int index, E element)
4.LinkedList: addFirst(E o)
5.LinkedList: addLast(E o)
6.LinkedList: clear()
7.LinkedList: get(int index)
8.LinkedList: getFirst()
9.LinkedList: getLast()
10.LinkedList: indexOf(Object o)
11.LinkedList: iterator()
12.LinkedList: lastIndexOf(Object o)
13.LinkedList: remove(int index)
14.LinkedList: remove(Object o)
15.LinkedList: removeFirst()
16.LinkedList: removeLast()
17.LinkedList: set(int index, E element)
18.LinkedList: toArray(T[] a)