Posts

Showing posts from November, 2019

Java Stream API

Image
Introduction Java stream API is not a really new API. This API has been introduced by Oracle since Java version 8. As specified inside the JDK documentation, Java stream is  A sequence of elements supporting sequential and parallel aggregate operations (source: https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html). Stream API, when used properly, can help the use of collections simpler and easier, following the way of doing functional programming . Java stream API has plenty of operations available. In today's post, we are going to run through some of the available operations provided by the stream API, including the sample source code and output from it. Due to so many operations available, we will limit our discussion to just several functions. For the rest of the discussion, we will consider having TWO (2) classes, Student and ClassRoom . The code for the 2 classes is as below. public class Student { private int age ; private String name ;