1.

How Will You Print Count Of Empty Strings In Java 8?

Answer»

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

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



Discussion

No Comment Found