Added in API level 1

Iterable

public interface Iterable

java.lang.Iterable<T>
AbstractCollection<E> This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface. 
AbstractList<E> This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array). 
AbstractQueue<E> This class provides skeletal implementations of some Queue operations. 
AbstractSequentialList<E> This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "sequential access" data store (such as a linked list). 
AbstractSet<E> This class provides a skeletal implementation of the Set interface to minimize the effort required to implement this interface. 
AlphabeticIndex<V> AlphabeticIndex supports the creation of a UI index appropriate for a given language. 
AlphabeticIndex.Bucket<V> An index "bucket" with a label string and type. 
AlphabeticIndex.ImmutableIndex<V> Immutable, thread-safe version of AlphabeticIndex
ArrayBlockingQueue<E> A bounded blocking queue backed by an array. 
ArrayDeque<E> Resizable-array implementation of the Deque interface. 
ArrayList<E> Resizable-array implementation of the List interface. 
ArraySet<E> ArraySet is a generic set data structure that is designed to be more memory efficient than a traditional HashSet
BatchUpdateException The subclass of SQLException thrown when an error occurs during a batch update operation. 
BlockingDeque<E> A Deque that additionally supports blocking operations that wait for the deque to become non-empty when retrieving an element, and wait for space to become available in the deque when storing an element. 
BlockingQueue<E> A Queue that additionally supports operations that wait for the queue to become non-empty when retrieving an element, and wait for space to become available in the queue when storing an element. 
Collection<E> The root interface in the collection hierarchy
ConcurrentHashMap.KeySetView<K, V> A view of a ConcurrentHashMap as a Set of keys, in which additions may optionally be enabled by mapping to a common value. 
ConcurrentLinkedDeque<E> An unbounded concurrent deque based on linked nodes. 
ConcurrentLinkedQueue<E> An unbounded thread-safe queue based on linked nodes. 
ConcurrentSkipListSet<E> A scalable concurrent NavigableSet implementation based on a ConcurrentSkipListMap
CopyOnWriteArrayList<E> A thread-safe variant of ArrayList in which all mutative operations (add, set, and so on) are implemented by making a fresh copy of the underlying array. 
CopyOnWriteArraySet<E> A Set that uses an internal CopyOnWriteArrayList for all of its operations. 
CursorJoiner Does a join on two cursors using the specified columns. 
DataTruncation An exception thrown as a DataTruncation exception (on writes) or reported as a DataTruncation warning (on reads) when a data values is unexpectedly truncated for reasons other than its having execeeded MaxFieldSize
DelayQueue<E extends Delayed> An unbounded blocking queue of Delayed elements, in which an element generally becomes eligible for removal when its delay has expired. 
Deque<E> A linear collection that supports element insertion and removal at both ends. 
DirectoryStream<T> An object to iterate over the entries in a directory. 
EnumSet<E extends Enum<E>> A specialized Set implementation for use with enum types. 
HashSet<E> This class implements the Set interface, backed by a hash table (actually a HashMap instance). 
LinkedBlockingDeque<E> An optionally-bounded blocking deque based on linked nodes. 
LinkedBlockingQueue<E> An optionally-bounded blocking queue based on linked nodes. 
LinkedHashSet<E>

Hash table and linked list implementation of the Set interface, with well-defined encounter order. 

LinkedList<E> Doubly-linked list implementation of the List and Deque interfaces. 
LinkedTransferQueue<E> An unbounded TransferQueue based on linked nodes. 
List<E> An ordered collection, where the user has precise control over where in the list each element is inserted. 
NavigableSet<E> A SortedSet extended with navigation methods reporting closest matches for given search targets. 
Path An object that may be used to locate a file in a file system. 
PriorityBlockingQueue<E> An unbounded blocking queue that uses the same ordering rules as class PriorityQueue and supplies blocking retrieval operations. 
PriorityQueue<E> An unbounded priority queue based on a priority heap. 
PropertyPath Represents a property path returned from searching the AppSearch Database. 
Queue<E> A collection designed for holding elements prior to processing. 
SQLClientInfoException The subclass of SQLException is thrown when one or more client info properties could not be set on a Connection
SQLDataException The subclass of SQLException thrown when the SQLState class value is '22', or under vendor-specified conditions. 
SQLException

An exception that provides information on a database access error or other errors. 

SQLFeatureNotSupportedException The subclass of SQLException thrown when the SQLState class value is '0A' ( the value is 'zero' A). 
SQLIntegrityConstraintViolationException The subclass of SQLException thrown when the SQLState class value is '23', or under vendor-specified conditions. 
SQLInvalidAuthorizationSpecException The subclass of SQLException thrown when the SQLState class value is '28', or under vendor-specified conditions. 
SQLNonTransientConnectionException The subclass of SQLException thrown for the SQLState class value '08', or under vendor-specified conditions. 
SQLNonTransientException The subclass of SQLException thrown when an instance where a retry of the same operation would fail unless the cause of the SQLException is corrected. 
SQLRecoverableException The subclass of SQLException thrown in situations where a previously failed operation might be able to succeed if the application performs some recovery steps and retries the entire transaction or in the case of a distributed transaction, the transaction branch. 
SQLSyntaxErrorException The subclass of SQLException thrown when the SQLState class value is '42', or under vendor-specified conditions. 
SQLTimeoutException

The subclass of SQLException thrown when the timeout specified by Statement has expired. 

SQLTransactionRollbackException The subclass of SQLException thrown when the SQLState class value is '40', or under vendor-specified conditions. 
SQLTransientConnectionException The subclass of SQLException for the SQLState class value '08', or under vendor-specified conditions. 
SQLTransientException The subclass of SQLException is thrown in situations where a previoulsy failed operation might be able to succeed when the operation is retried without any intervention by application-level functionality. 
SQLWarning

An exception that provides information on database access warnings. 

SecureDirectoryStream<T> A DirectoryStream that defines operations on files that are located relative to an open directory. 
SequencedCollection<E> A collection that has a well-defined encounter order, that supports operations at both ends, and that is reversible. 
SequencedSet<E> A collection that is both a SequencedCollection and a Set
ServiceLoader<S> A facility to load implementations of a service. 
Set<E> A collection that contains no duplicate elements. 
SortedSet<E> A Set that further provides a total ordering on its elements. 
Stack<E> The Stack class represents a last-in-first-out (LIFO) stack of objects. 
SynchronousQueue<E> A blocking queue in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa. 
TextUtils.SimpleStringSplitter A simple string splitter. 
TextUtils.StringSplitter An interface for splitting strings according to rules that are opaque to the user of this interface. 
TransferQueue<E> A BlockingQueue in which producers may wait for consumers to receive elements. 
TreeSet<E> A NavigableSet implementation based on a TreeMap
UnicodeSet A mutable set of Unicode characters and multicharacter strings. 
Vector<E> The Vector class implements a growable array of objects. 


Implementing this interface allows an object to be the target of the enhanced for statement (sometimes called the "for-each loop" statement).

Summary

Public methods

default void forEach(Consumer<? super T> action)

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

abstract Iterator<T> iterator()

Returns an iterator over elements of type T.

default Spliterator<T> spliterator()

Creates a Spliterator over the elements described by this Iterable.

Public methods

forEach

Added in API level 24
public void forEach (Consumer<? super T> action)

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.

The behavior of this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy.

Implementation Requirements:
  • The default implementation behaves as if:

    for (T t : this)
             action.accept(t);
     
Parameters
action Consumer: The action to be performed for each element

Throws
NullPointerException if the specified action is null

iterator

Added in API level 1
public abstract Iterator<T> iterator ()

Returns an iterator over elements of type T.

Returns
Iterator<T> an Iterator.

spliterator

Added in API level 24
public Spliterator<T> spliterator ()

Creates a Spliterator over the elements described by this Iterable.

Implementation Requirements:
  • The default implementation creates an early-binding spliterator from the iterable's Iterator. The spliterator inherits the fail-fast properties of the iterable's iterator.
Implementation Note:
  • The default implementation should usually be overridden. The spliterator returned by the default implementation has poor splitting capabilities, is unsized, and does not report any spliterator characteristics. Implementing classes can nearly always provide a better implementation.
Returns
Spliterator<T> a Spliterator over the elements described by this Iterable.