Java8: Streams

Photo by Good Free Photos on Unsplash
List<String> names = Arrays.asList("nuwan","","chamara","sena");
List<String> validNames = ->!s.isEmpty()).collect(Collectors.toList());
System.out.println(", ")));
List<Integer> numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5);
List<Integer> squaresList
.map(i -> i*i).distinct().collect(Collectors.toList());
IntSummaryStatistics statistics = -> i).summaryStatistics();
System.out.println("Stats: "+statistics.getMax()+" "+ statistics.getSum()+" "+ statistics.getAverage());
System.out.println("Count: "+squaresList.parallelStream().count());



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nuwan Zen

Nuwan Zen

Sometimes A software Engineer, sometimes a support engineer, sometimes a devops engineer, sometimes a cloud engineer :D That’s how the this life goes!