To compile, the second must be
collectionOfThings. stream(). filter(thing -> thing.condition1()). filter(thing -> thing.condition2())
They are both equivalent. Sometimes one of them is more readable than the other.
An alternative way to write the second is to use a method reference:
collectionOfThings .stream() .filter(Thing::condition1) .filter(Thing::condition2)
Also note that the convention is to put a dot at the beginning of the line, and not at the end, since you would write a bulleted list.
source share