in Education by

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

Please log in or register to answer this question.

1 Answer

0 votes
by

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();

Related questions

...