Filtering and counting elements using Java 8 Streams

This is NOT the official website
of Java.
List<String> strings = Arrays.asList("a", "", "b", "", "c");
 
// Count the non-empty strings
long nonEmptyCount = strings.stream()
        .filter(x -> !x.isEmpty())
        .count();3
 
// Count the empty strings
long emptyCount = strings.stream()
        .filter(String::isEmpty) // same as .filter(x -> x.isEmpty())
        .count();2