Here you can find the source of toIterable(final T[] arr)
public static <T> Iterable<T> toIterable(final T[] arr)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T> Iterable<T> toIterable(final T[] arr) { return new Iterable<T>() { @Override//from w ww .j a va 2 s . co m public Iterator<T> iterator() { return new Iterator<T>() { int index = 0; @Override public boolean hasNext() { return index < arr.length; } @Override public T next() { return arr[index++]; } @Override public void remove() { throw new RuntimeException("Not supported"); } }; } }; } }