While Stream#anyMatch returns false for an empty stream, Stream#allMatch and Stream#noneMatch return true for an empty stream.
Why is the behaviour of anyMatch different from that of allMatch and noneMatch for an empty Stream?
While Stream#anyMatch returns false for an empty stream, Stream#allMatch and Stream#noneMatch return true for an empty stream.
Why is the behaviour of anyMatch different from that of allMatch and noneMatch for an empty Stream?
Stream#anyMatch evaluates the existential quantification of the predicate over the elements of the stream. The existential quantification always evaluates to false for an empty set.
On the other hand, Stream#allMatch evaluates the universal quantification of the predicate over the elements of the stream and Stream#noneMatch evaluates the universal quantification of the negated predicate over the elements of the stream. The universal quantification always evaluates to true for an empty set.