The code to print count of empty strings in Java 8 is:-

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

//get a count of empty string

long count = strings.p

arallelStream().filter(string -> string.isEmpty()).count();

Point to be noted: Go through this Q&A very thoroughly as this is one of the most

asked java 8 interview questions.

Example

                                        
List<String>strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");
int count = strings.stream().filter(string −> string.isEmpty()).count();

Suggest An Answer

No suggestions avaliable!