Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/lang/Iterable#pubmethods)

# Iterable

` public interface Iterable `   
` `

|---|
| java.lang.Iterable\<T\> |

Known indirect subclasses [AbstractCollection](https://developer.android.com/reference/java/util/AbstractCollection)\<E\>, [AbstractList](https://developer.android.com/reference/java/util/AbstractList)\<E\>, [AbstractQueue](https://developer.android.com/reference/java/util/AbstractQueue)\<E\>, [AbstractSequentialList](https://developer.android.com/reference/java/util/AbstractSequentialList)\<E\>, [AbstractSet](https://developer.android.com/reference/java/util/AbstractSet)\<E\>, [AlphabeticIndex](https://developer.android.com/reference/android/icu/text/AlphabeticIndex)\<V\>, [AlphabeticIndex.Bucket](https://developer.android.com/reference/android/icu/text/AlphabeticIndex.Bucket)\<V\>, [AlphabeticIndex.ImmutableIndex](https://developer.android.com/reference/android/icu/text/AlphabeticIndex.ImmutableIndex)\<V\>, [ArrayBlockingQueue](https://developer.android.com/reference/java/util/concurrent/ArrayBlockingQueue)\<E\>, [ArrayDeque](https://developer.android.com/reference/java/util/ArrayDeque)\<E\>, [ArrayList](https://developer.android.com/reference/java/util/ArrayList)\<E\>, [ArraySet](https://developer.android.com/reference/android/util/ArraySet)\<E\>, [BatchUpdateException](https://developer.android.com/reference/java/sql/BatchUpdateException), [BlockingDeque](https://developer.android.com/reference/java/util/concurrent/BlockingDeque)\<E\>, [BlockingQueue](https://developer.android.com/reference/java/util/concurrent/BlockingQueue)\<E\>, and 55 others. [AbstractCollection](https://developer.android.com/reference/java/util/AbstractCollection)\<E\> This class provides a skeletal implementation of the `Collection` interface, to minimize the effort required to implement this interface. [AbstractList](https://developer.android.com/reference/java/util/AbstractList)\<E\> This class provides a skeletal implementation of the `https://developer.android.com/reference/java/util/List` interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array). [AbstractQueue](https://developer.android.com/reference/java/util/AbstractQueue)\<E\> This class provides skeletal implementations of some `https://developer.android.com/reference/java/util/Queue` operations. [AbstractSequentialList](https://developer.android.com/reference/java/util/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](https://developer.android.com/reference/java/util/AbstractSet)\<E\> This class provides a skeletal implementation of the `Set` interface to minimize the effort required to implement this interface. [AlphabeticIndex](https://developer.android.com/reference/android/icu/text/AlphabeticIndex)\<V\> AlphabeticIndex supports the creation of a UI index appropriate for a given language. [AlphabeticIndex.Bucket](https://developer.android.com/reference/android/icu/text/AlphabeticIndex.Bucket)\<V\> An index "bucket" with a label string and type. [AlphabeticIndex.ImmutableIndex](https://developer.android.com/reference/android/icu/text/AlphabeticIndex.ImmutableIndex)\<V\> Immutable, thread-safe version of `https://developer.android.com/reference/android/icu/text/AlphabeticIndex`. [ArrayBlockingQueue](https://developer.android.com/reference/java/util/concurrent/ArrayBlockingQueue)\<E\> A bounded [blocking queue](https://developer.android.com/reference/java/util/concurrent/BlockingQueue) backed by an array. [ArrayDeque](https://developer.android.com/reference/java/util/ArrayDeque)\<E\> Resizable-array implementation of the `https://developer.android.com/reference/java/util/Deque` interface. [ArrayList](https://developer.android.com/reference/java/util/ArrayList)\<E\> Resizable-array implementation of the `List` interface. [ArraySet](https://developer.android.com/reference/android/util/ArraySet)\<E\> ArraySet is a generic set data structure that is designed to be more memory efficient than a traditional `https://developer.android.com/reference/java/util/HashSet`. [BatchUpdateException](https://developer.android.com/reference/java/sql/BatchUpdateException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when an error occurs during a batch update operation. [BlockingDeque](https://developer.android.com/reference/java/util/concurrent/BlockingDeque)\<E\> A `https://developer.android.com/reference/java/util/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](https://developer.android.com/reference/java/util/concurrent/BlockingQueue)\<E\> A `https://developer.android.com/reference/java/util/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](https://developer.android.com/reference/java/util/Collection)\<E\> The root interface in the *collection hierarchy*. [ConcurrentHashMap.KeySetView](https://developer.android.com/reference/java/util/concurrent/ConcurrentHashMap.KeySetView)\<K, V\> A view of a ConcurrentHashMap as a `https://developer.android.com/reference/java/util/Set` of keys, in which additions may optionally be enabled by mapping to a common value. [ConcurrentLinkedDeque](https://developer.android.com/reference/java/util/concurrent/ConcurrentLinkedDeque)\<E\> An unbounded concurrent [deque](https://developer.android.com/reference/java/util/Deque) based on linked nodes. [ConcurrentLinkedQueue](https://developer.android.com/reference/java/util/concurrent/ConcurrentLinkedQueue)\<E\> An unbounded thread-safe [queue](https://developer.android.com/reference/java/util/Queue) based on linked nodes. [ConcurrentSkipListSet](https://developer.android.com/reference/java/util/concurrent/ConcurrentSkipListSet)\<E\> A scalable concurrent `https://developer.android.com/reference/java/util/NavigableSet` implementation based on a `https://developer.android.com/reference/java/util/concurrent/ConcurrentSkipListMap`. [CopyOnWriteArrayList](https://developer.android.com/reference/java/util/concurrent/CopyOnWriteArrayList)\<E\> A thread-safe variant of `https://developer.android.com/reference/java/util/ArrayList` in which all mutative operations (`add`, `set`, and so on) are implemented by making a fresh copy of the underlying array. [CopyOnWriteArraySet](https://developer.android.com/reference/java/util/concurrent/CopyOnWriteArraySet)\<E\> A `https://developer.android.com/reference/java/util/Set` that uses an internal `https://developer.android.com/reference/java/util/concurrent/CopyOnWriteArrayList` for all of its operations. [CursorJoiner](https://developer.android.com/reference/android/database/CursorJoiner) Does a join on two cursors using the specified columns. [DataTruncation](https://developer.android.com/reference/java/sql/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](https://developer.android.com/reference/java/util/concurrent/DelayQueue)\<E extends [Delayed](https://developer.android.com/reference/java/util/concurrent/Delayed)\> An unbounded [blocking queue](https://developer.android.com/reference/java/util/concurrent/BlockingQueue) of `https://developer.android.com/reference/java/util/concurrent/Delayed` elements, in which an element generally becomes eligible for removal when its delay has expired. [Deque](https://developer.android.com/reference/java/util/Deque)\<E\> A linear collection that supports element insertion and removal at both ends. [DirectoryStream](https://developer.android.com/reference/java/nio/file/DirectoryStream)\<T\> An object to iterate over the entries in a directory. [EnumSet](https://developer.android.com/reference/java/util/EnumSet)\<E extends [Enum](https://developer.android.com/reference/java/lang/Enum)\<E\>\> A specialized `https://developer.android.com/reference/java/util/Set` implementation for use with enum types. [HashSet](https://developer.android.com/reference/java/util/HashSet)\<E\> This class implements the `Set` interface, backed by a hash table (actually a `HashMap` instance). [LinkedBlockingDeque](https://developer.android.com/reference/java/util/concurrent/LinkedBlockingDeque)\<E\> An optionally-bounded [blocking deque](https://developer.android.com/reference/java/util/concurrent/BlockingDeque) based on linked nodes. [LinkedBlockingQueue](https://developer.android.com/reference/java/util/concurrent/LinkedBlockingQueue)\<E\> An optionally-bounded [blocking queue](https://developer.android.com/reference/java/util/concurrent/BlockingQueue) based on linked nodes. [LinkedHashSet](https://developer.android.com/reference/java/util/LinkedHashSet)\<E\> Hash table and linked list implementation of the `Set` interface, with well-defined encounter order.
[LinkedList](https://developer.android.com/reference/java/util/LinkedList)\<E\> Doubly-linked list implementation of the `List` and `Deque` interfaces. [LinkedTransferQueue](https://developer.android.com/reference/java/util/concurrent/LinkedTransferQueue)\<E\> An unbounded `https://developer.android.com/reference/java/util/concurrent/TransferQueue` based on linked nodes. [List](https://developer.android.com/reference/java/util/List)\<E\> An ordered collection, where the user has precise control over where in the list each element is inserted. [NavigableSet](https://developer.android.com/reference/java/util/NavigableSet)\<E\> A `https://developer.android.com/reference/java/util/SortedSet` extended with navigation methods reporting closest matches for given search targets. [Path](https://developer.android.com/reference/java/nio/file/Path) An object that may be used to locate a file in a file system. [PriorityBlockingQueue](https://developer.android.com/reference/java/util/concurrent/PriorityBlockingQueue)\<E\> An unbounded [blocking queue](https://developer.android.com/reference/java/util/concurrent/BlockingQueue) that uses the same ordering rules as class `https://developer.android.com/reference/java/util/PriorityQueue` and supplies blocking retrieval operations. [PriorityQueue](https://developer.android.com/reference/java/util/PriorityQueue)\<E\> An unbounded priority [queue](https://developer.android.com/reference/java/util/Queue) based on a priority heap. [PropertyPath](https://developer.android.com/reference/android/app/appsearch/PropertyPath) Represents a property path returned from searching the AppSearch Database. [Queue](https://developer.android.com/reference/java/util/Queue)\<E\> A collection designed for holding elements prior to processing. [SQLClientInfoException](https://developer.android.com/reference/java/sql/SQLClientInfoException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` is thrown when one or more client info properties could not be set on a `Connection`. [SQLDataException](https://developer.android.com/reference/java/sql/SQLDataException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when the SQLState class value is '*22*', or under vendor-specified conditions. [SQLException](https://developer.android.com/reference/java/sql/SQLException) An exception that provides information on a database access error or other errors.
[SQLFeatureNotSupportedException](https://developer.android.com/reference/java/sql/SQLFeatureNotSupportedException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when the SQLState class value is '*0A*' ( the value is 'zero' A). [SQLIntegrityConstraintViolationException](https://developer.android.com/reference/java/sql/SQLIntegrityConstraintViolationException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when the SQLState class value is '*23*', or under vendor-specified conditions. [SQLInvalidAuthorizationSpecException](https://developer.android.com/reference/java/sql/SQLInvalidAuthorizationSpecException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when the SQLState class value is '*28*', or under vendor-specified conditions. [SQLNonTransientConnectionException](https://developer.android.com/reference/java/sql/SQLNonTransientConnectionException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown for the SQLState class value '*08*', or under vendor-specified conditions. [SQLNonTransientException](https://developer.android.com/reference/java/sql/SQLNonTransientException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when an instance where a retry of the same operation would fail unless the cause of the `SQLException` is corrected. [SQLRecoverableException](https://developer.android.com/reference/java/sql/SQLRecoverableException) The subclass of `https://developer.android.com/reference/java/sql/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](https://developer.android.com/reference/java/sql/SQLSyntaxErrorException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when the SQLState class value is '*42*', or under vendor-specified conditions. [SQLTimeoutException](https://developer.android.com/reference/java/sql/SQLTimeoutException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when the timeout specified by `Statement` has expired.
[SQLTransactionRollbackException](https://developer.android.com/reference/java/sql/SQLTransactionRollbackException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` thrown when the SQLState class value is '*40*', or under vendor-specified conditions. [SQLTransientConnectionException](https://developer.android.com/reference/java/sql/SQLTransientConnectionException) The subclass of `https://developer.android.com/reference/java/sql/SQLException` for the SQLState class value '*08*', or under vendor-specified conditions. [SQLTransientException](https://developer.android.com/reference/java/sql/SQLTransientException) The subclass of `https://developer.android.com/reference/java/sql/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](https://developer.android.com/reference/java/sql/SQLWarning) An exception that provides information on database access warnings.
[SecureDirectoryStream](https://developer.android.com/reference/java/nio/file/SecureDirectoryStream)\<T\> A `DirectoryStream` that defines operations on files that are located relative to an open directory. [SequencedCollection](https://developer.android.com/reference/java/util/SequencedCollection)\<E\> A collection that has a well-defined encounter order, that supports operations at both ends, and that is reversible. [SequencedSet](https://developer.android.com/reference/java/util/SequencedSet)\<E\> A collection that is both a `https://developer.android.com/reference/java/util/SequencedCollection` and a `https://developer.android.com/reference/java/util/Set`. [ServiceLoader](https://developer.android.com/reference/java/util/ServiceLoader)\<S\> A facility to load implementations of a service. [Set](https://developer.android.com/reference/java/util/Set)\<E\> A collection that contains no duplicate elements. [SortedSet](https://developer.android.com/reference/java/util/SortedSet)\<E\> A `https://developer.android.com/reference/java/util/Set` that further provides a *total ordering* on its elements. [Stack](https://developer.android.com/reference/java/util/Stack)\<E\> The `Stack` class represents a last-in-first-out (LIFO) stack of objects. [SynchronousQueue](https://developer.android.com/reference/java/util/concurrent/SynchronousQueue)\<E\> A [blocking queue](https://developer.android.com/reference/java/util/concurrent/BlockingQueue) in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa. [TextUtils.SimpleStringSplitter](https://developer.android.com/reference/android/text/TextUtils.SimpleStringSplitter) A simple string splitter. [TextUtils.StringSplitter](https://developer.android.com/reference/android/text/TextUtils.StringSplitter) An interface for splitting strings according to rules that are opaque to the user of this interface. [TransferQueue](https://developer.android.com/reference/java/util/concurrent/TransferQueue)\<E\> A `https://developer.android.com/reference/java/util/concurrent/BlockingQueue` in which producers may wait for consumers to receive elements. [TreeSet](https://developer.android.com/reference/java/util/TreeSet)\<E\> A `https://developer.android.com/reference/java/util/NavigableSet` implementation based on a `https://developer.android.com/reference/java/util/TreeMap`. [UnicodeSet](https://developer.android.com/reference/android/icu/text/UnicodeSet) A mutable set of Unicode characters and multicharacter strings. [Vector](https://developer.android.com/reference/java/util/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` | ` https://developer.android.com/reference/java/lang/Iterable#forEach(java.util.function.Consumer<?%20super%20T>)(https://developer.android.com/reference/java/util/function/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 https://developer.android.com/reference/java/util/Iterator<T>` | ` https://developer.android.com/reference/java/lang/Iterable#iterator()() ` Returns an iterator over elements of type `T`. |
| ` default https://developer.android.com/reference/java/util/Spliterator<T>` | ` https://developer.android.com/reference/java/lang/Iterable#spliterator()() ` Creates a `https://developer.android.com/reference/java/util/Spliterator` over the elements described by this `Iterable`. |

## Public methods

### forEach

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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.

<br />

##### 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 <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if the specified action is null |

### iterator

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Iterator<T> iterator ()
```

Returns an iterator over elements of type `T`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Iterator<T>` | an Iterator. <br /> |

### spliterator

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Spliterator<T> spliterator ()
```

Creates a `https://developer.android.com/reference/java/util/Spliterator` over the elements described by this `Iterable`.

<br />

##### 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.

##### Implementation Requirements:

- The default implementation creates an *[early-binding](https://developer.android.com/reference/java/util/Spliterator.html#binding)* spliterator from the iterable's `Iterator`. The spliterator inherits the *fail-fast* properties of the iterable's iterator.

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Spliterator<T>` | a `Spliterator` over the elements described by this `Iterable`. <br /> |