Similar to filtering a collection or counting the number of occurrences in a list this example will count the number of non empty strings in a collection. In a related example we demonstrate count non null or empty elements in arraylist using groovy.
Straight up Java
Java 8
Google Guava