~/ 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/6b691496-30e0-414d-84d2-d9356b283af9/flashcard utf-8 LF