Here you can find the source of stream(Collection
public static <T> Stream<T> stream(Collection<T> collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Collections; import java.util.Optional; import java.util.stream.Stream; public class Main { public static <T> Stream<T> stream(Collection<T> collection) { return Optional.ofNullable(collection).orElseGet(Collections::emptyList).stream(); }//from w w w . j a v a 2 s . co m }