Collection: size() Returns the number of elements in this collection : Collection « Utility Classes « SCJP






import java.util.ArrayList;
import java.util.Collection;

public class MainClass {
  public static void main(String[] argv) {
    Collection c = new ArrayList();
    c.add("1");
    c.add("2");
    c.add("3");

    System.out.println(c.size());

  }
}
3








8.11.Collection
8.11.1.The central interfaces of he Collections Framework are
8.11.2.Collection: add(Object x) Adds x to this collection
8.11.3.Collection: addAll(Collection c) Adds every element of c to this collection
8.11.4.Collection: clear() Removes every element from this collection
8.11.5.Collection: contains(Object x) Returns true if this collection contains x
8.11.6.Collection: containsAll(Collection c) Returns true if this collection contains every element of c
8.11.7.Collection: isEmpty() Returns true if this collection contains no elements
8.11.8.iterator() Returns an Iterator over this collection (see below)
8.11.9.Collection: remove(Object x) Removes x from this collection
8.11.10.Collection: removeAll(Collection c) Removes every element in c from this collection
8.11.11.Collection: retainAll(Collection c) Removes from this collection every element that is not in c
8.11.12.Collection: size() Returns the number of elements in this collection
8.11.13.Collection: toArray() Returns an array containing the elements in this collection