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






ArrayList: clear()

  

import java.util.ArrayList;
import java.util.List;

public class Main {
  public static void main(String args[]) throws Exception {

    List<String> list = new ArrayList<String>();
    list.add("A");
    list.add("B");
    list.add("C");
    list.clear();

    System.out.println(list);
  }
}

   
    
  








Related examples in the same category

1.new ArrayList < E > ()
2.new ArrayList(Collection c)
3.ArrayList: add(E o)
4.ArrayList: add(int index, E element)
5.ArrayList: addAll(Collection c)
6.ArrayList: addAll(int index, Collection c)
7.ArrayList: contains(Object elem)
8.ArrayList: equals(Object o)
9.ArrayList: ensureCapacity(int minCapacity)
10.ArrayList: get(int index)
11.ArrayList: indexOf(Object elem)
12.ArrayList: isEmpty()
13.ArrayList: iterator()
14.ArrayList: lastIndexOf(Object o)
15.ArrayList: listIterator()
16.ArrayList: remove(int index)
17.ArrayList: remove(Object o)
18.ArrayList: removeAll(Collection c)
19.ArrayList: retainAll(Collection c)
20.ArrayList: set(int index, T element)
21.ArrayList: size()
22.AbstractList: subList(int fromIndex, int toIndex)
23.ArrayList: toArray()
24.ArrayList: toArray(T[] a)
25.ArrayList: trimToSize()
26.for each loop for ArrayList