~/ learn/ java-from-zero/ cards/ Built-in functional interfaces (java.util.function)
1 of 4

Type a Predicate that tests if a String is longer than five chars

Type a Predicate that tests if a String is longer than five chars

Answer

Predicate<String> long5 = s -> s.length() > 5;

Predicate<T> has one abstract method: boolean test(T t). It is the natural type for filter conditions.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/e17f6566-5fd0-4dc0-a6b0-8b23459362fb/flashcard utf-8 LF