It's been couple of weeks Java 8 has released and lot of Java developers are trying their hands on major enhancement e.g. lambda expression, method reference, new data and time classes, and more importantly Stream API for bulk data operations. In my opinion, best way to learn any new feature or functionality is by writing short examples, and this is what prompt me to write this article. In this Java 8 tutorial, I have shared simple examples of
java.util.Stream package. Streams are one of the most important addition on JDK, it allows you to leverage other changes e.g. lambda expression, method reference, functional interface and internal iteration introduced via
forEach() method. Some of the most common things we do with Streams are filtering a collection, applying map and reduce function on all elements of collection and taking advantage of lazy evaluation, built-in parallelism via
parallelStream(). This is by no means a complete set of examples you need to master Java 8 Stream API, but it will introduce with key functions and encourage you to explore by yourself by reading Java documentation and trying them. If you like to also learn lambda expression in details, you can check my post
10 ways to use lambda expression in Java 8.