Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Java reference

Stream.noneMatch()

Checks that no element matches a condition.

Available since: Java 8

Syntax

boolean noneMatch(Predicate<? super T> predicate)

Parameters

ParameterTypeDescription
predicatePredicate<? super T>The condition to check.

Return value

boolean`true` if no element matches.

Examples

Are there no negative values:

void main() {
    IO.println(List.of(3, 0, 7).stream().noneMatch(n -> n < 0));
    IO.println(List.of(3, -1, 7).stream().noneMatch(n -> n < 0));
}

Output:

true
false

Notes

noneMatch(p) is the same as !anyMatch(p) but reads without a negation. On an empty stream it returns true.

See also

Related recipes

In the tutorial

  • Stream operations — The main Stream API operations — filter, map, sorted, distinct, limit, skip, count, reduce, anyMatch, findFirst and numeric streams.

Thanks for reading!

Donate to the site — we work hard for you.