Here you can find the source of toIterator(final T[] data)
public static <T> Iterator<T> toIterator(final T[] data)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { /**// ww w . j a va 2 s . c o m * Creates an iterator over the supplied array. If the array is null, null is returned. */ public static <T> Iterator<T> toIterator(final T[] data) { if (data == null) { return null; } return new Iterator<T>() { public boolean hasNext() { return (_index < data.length); } public T next() { return data[_index++]; } public void remove() { throw new RuntimeException("remove() not possible"); } protected int _index; }; } }