LinkedList: clear() : LinkedList « java.util « Java by API






LinkedList: clear()

 
import java.util.LinkedList;

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("LinkedList contains : " + lList);
    lList.clear();
    System.out.println("LinkedList now contains : " + 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: get(int index)
7.LinkedList: getFirst()
8.LinkedList: getLast()
9.LinkedList: indexOf(Object o)
10.LinkedList: iterator()
11.LinkedList: lastIndexOf(Object o)
12.LinkedList: remove(int index)
13.LinkedList: remove(Object o)
14.LinkedList: removeFirst()
15.LinkedList: removeLast()
16.LinkedList: set(int index, E element)
17.LinkedList: subList(int fromIndex, int toIndex)
18.LinkedList: toArray(T[] a)