Here you can find the source of asStream(Iterable
public static <T> Stream<T> asStream(Iterable<T> sourceIterable)
//package com.java2s; //License from project: Apache License import java.util.Iterator; import java.util.stream.Stream; import java.util.stream.StreamSupport; public class Main { public static <T> Stream<T> asStream(Iterable<T> sourceIterable) { return asStream(sourceIterable.iterator()); }//w w w.j ava 2 s . c o m public static <T> Stream<T> asStream(Iterator<T> sourceIterator) { return asStream(sourceIterator, false); } public static <T> Stream<T> asStream(Iterator<T> sourceIterator, boolean parallel) { Iterable<T> iterable = () -> sourceIterator; return StreamSupport.stream(iterable.spliterator(), parallel); } }