Java – how do I check if NULL is in the stream?
•
Java
I have a stream < integer > and want to know if there is space in this stream How to check? use. Anymatch (null) gives me a Java lang.NullPointerException.
Solution
Anymatch accepts predicates
stream.anyMatch(x -> x == null)
or
stream.anyMatch(Objects::isNull)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码