0
List<String>strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");

Open 1 Answers 26 Views Education

List<String>strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");

1 Answer

0

How will you print count of empty strings in Java 8?

The following code segment prints a count of empty strings using filter.

List<String>strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");

//get count of empty string

int count = strings.stream().filter(string -> string.isEmpty()).count();

by (52.6k points)
...