Interface Iterable<T>

All Known Subinterfaces:
Collection<E>, Deque<E>, List<E>, NavigableSet<E>, Queue<E>, Set<E>, SortedSet<E>
All Known Implementing Classes:
AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet, ArrayDeque, ArrayList, ConcurrentHashMap.KeySetView, CopyOnWriteArrayList, CopyOnWriteArraySet, HashSet, LinkedHashSet, LinkedList, PriorityQueue, Stack, TreeSet, Vector

public interface Iterable<T>

Objects of classes that implement this interface can be used within a foreach statement.

Since

1.5

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    forEach(Consumer<? super T> action)
    Performs the given action for each element of the Iterable.
    Returns an Iterator for the elements in this object.
    default Spliterator<T>
    The elements, as a Spliterator whose size is not known.
  • Method Details

    • iterator

      Iterator<T> iterator()

      Returns an Iterator for the elements in this object.

      Returns

      An Iterator instance.

    • forEach

      default void forEach(Consumer<? super T> action)
      Performs the given action for each element of the Iterable. Stubbed in the CLDC11 subset; the actual implementation comes from the platform's JDK at runtime.
    • spliterator

      default Spliterator<T> spliterator()
      The elements, as a Spliterator whose size is not known.