in Education by

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

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

0 votes
asked Dec 31, 2021 in Education by JackTerrance
0 votes
asked Oct 24, 2021 in Education by JackTerrance
0 votes
asked Oct 11, 2021 in Education by JackTerrance
...