Google is committed to advancing racial equity for Black communities. See how.
Added in API level 1

Iterable

interface Iterable<T : Any!>
java.lang.Iterable

Implementing this interface allows an object to be the target of the "for-each loop" statement. See For-each Loop

Summary

Public methods
open Unit
forEach(action: Consumer<in T>)

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

abstract MutableIterator<T>

Returns an iterator over elements of type T.

open Spliterator<T>

Creates a Spliterator over the elements described by this Iterable.

Public methods

forEach

Added in API level 24
open fun forEach(action: Consumer<in T>): Unit

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.

Parameters
action Consumer<in T>: The action to be performed for each element
Exceptions
java.lang.NullPointerException if the specified action is null

iterator

Added in API level 1
abstract fun iterator(): MutableIterator<T>

Returns an iterator over elements of type T.

Return
MutableIterator<T> an Iterator.

spliterator

Added in API level 24
open fun spliterator(): Spliterator<T>

Creates a Spliterator over the elements described by this Iterable.

Return
Spliterator<T> a Spliterator over the elements described by this Iterable.