Predicate.not( … )
java-11 offers a new method Predicate#not
So you can negate the method reference:
Stream<String> s = ...;
long nonEmptyStrings = s.filter(Predicate.not(String::isEmpty)).count();
More Related Contents:
- How to apply multiple predicates to a java.util.Stream?
- Built-in Java 8 predicate that always returns true?
- convert String list in List of object [duplicate]
- Is it possible to use Java 8 for Android development?
- Custom thread pool in Java 8 parallel stream
- What’s the difference between map() and flatMap() methods in Java 8?
- Java 8 lambdas, Function.identity() or t->t
- Reflection type inference on Java 8 Lambdas
- Why java.util.Optional is not Serializable, how to serialize the object with such fields
- Filter values only if not null using lambda in Java8
- Retrieving a List from a java.util.stream.Stream in Java 8
- Java 8: How do I work with exception throwing methods in streams?
- Java 8 LocalDateTime deserialized using Gson
- Why does Iterable not provide stream() and parallelStream() methods?
- Java Streams: How to do an efficient “distinct and sort”?
- How does combiner in Stream.collect method work in java 8?
- How to make a lambda expression define toString in Java 8?
- Why isn’t @FunctionalInterface used on all the interfaces in the JDK that qualify?
- How to make Selenium wait until an element is present?
- How can I throw CHECKED exceptions from inside Java 8 lambdas/streams?
- Parallel stream from a HashSet doesn’t run in parallel
- How to get a Stream from a float[]
- Difference between findAny() and findFirst() in Java 8
- Add Buttons to Tabs and Tab area JavaFX
- ‘Optional.get()’ without ‘isPresent()’ check
- Most elegant way to join a Map to a String in Java 8
- FunctionalInterface Comparator has 2 abstract methods
- Perform operation on n random distinct elements from Collection using Streams API
- How to combine 3 or more CompletionStages?
- Stream.peek() method in Java 8 vs Java 9