Java EE

Understanding Java Streams

Introduced in Java 8, the Stream API is used to process collections of objects.

A stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result.

List strings = Arrays.asList("abc", "", "bc", "efg", "abcd","", "jkl");
List filtered = strings.stream().filter(string -> !string.isEmpty()).collect(Collectors.toList());