How are lazy streams implemented in Java 8?
问题 I am reading Java 8, specifically the "Streams API". I wanted to know how streams can be lazy? I believe streams are just added as a library and there are no changes done to the language to support laziness. Also, I will be shocked if somebody tells me it's achieved through reflection. 回答1: Why would you need reflection to get laziness? For example, consider this class: class LazySeq<T> { private final List<T> list; private Predicate<? super T> predicate; public LazySeq(List<T> input) { this