It means that the filter is only applied during the terminal operation. Think of something like this:
public Stream filter(Predicate p) {
this.filter = p; // just store it, don't apply it yet
return this; // in reality: return a new stream
}
public List collect() {
for (Object o : stream) {
if (filter.test(o)) list.add(o);
}
return list;
}
(That does not compile and is a simplification of the reality but the principle is there)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…