Interface Collection

  • All Known Subinterfaces:
    List, Set, SortedSet
    All Known Implementing Classes:
    ArrayList, HashSet, LinkedList, SortedSetImpl

    public interface Collection
    The LEAP (environment-dependent) version of the &qote;java.util.Collection&qote; interface. This interface appears to be exactly the same in J2SE, PJAVA and MIDP. The internal implementation is different in the three cases however.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean add​(Object o)
      Adds an element.
      boolean isEmpty()
      Checks if the collection contains elements.
      Iterator iterator()
      Returns an iterator over the elements in this collection.
      boolean remove​(Object o)
      Removes one instance of the specified element.
      int size()
      Returns the number of elements in this collection.
      Object[] toArray()
      Returns an array containing all of the elements in this collection.
    • Method Detail

      • add

        boolean add​(Object o)
        Adds an element.
        Returns:
        true if the element has been added.
      • isEmpty

        boolean isEmpty()
        Checks if the collection contains elements.
        Returns:
        true if this collection contains no elements
      • remove

        boolean remove​(Object o)
        Removes one instance of the specified element.
        Parameters:
        o - the element to be removed
        Returns:
        true if the element has been removed
      • iterator

        Iterator iterator()
        Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned.
        Returns:
        an Iterator over the elements in this collection
      • toArray

        Object[] toArray()
        Returns an array containing all of the elements in this collection.
        Returns:
        an array containing all of the elements in this collection
      • size

        int size()
        Returns the number of elements in this collection.
        Returns:
        the number of elements in this collection.