, findFirst() Optional<String>, Stream String. , orElse boolean ( String).
A direct solution to your problem would be to use
findFirst().isPresent();
Thus, if it findFirst()returns an empty optional parameter, it isPresent()will return false, and if it does not, it will return true.
But it would be better to go with @Tagir Valeev's answer and use anyMatch.
source
share