Here you can find the source of toIterable(final T[] array)
public static <T> Iterable<T> toIterable(final T[] array)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; import java.util.NoSuchElementException; public class Main { public static <T> Iterable<T> toIterable(final T[] array) { return new Iterable<T>() { @Override/*from w w w .j a v a2 s .c o m*/ public Iterator<T> iterator() { return new Iterator<T>() { private int i; @Override public boolean hasNext() { return i < array.length; } @Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } return array[i++]; } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; } }