Predicates in Java8

Predicates are boolean valued functions which returns true/false based on some conditions. Simple. Predicate<T> in java is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference. Now let’s see how to use Predicates. We have one below Employee class and we want to filter out Employees based on some given conditions. Use Cases Print names of … Continue reading Predicates in Java8

Streams Versus Collections

Both are the old and new notions of  interfaces to a sequence of elements. So what’s the difference? In a nutshell, collections are about data and streams are about computations. Now imagine, when a movie is being streamed over internet. It is now a stream. The streaming video player needs to have downloaded only a few frames in advance of where the user is watching. Below text from … Continue reading Streams Versus Collections

Java 8 Stream APIs

Streams are not easy to debug 🙂 Java 8 Stream is here to ease our life as far as iteration over different Collections are concerned based on some filter conditions etc.   How we used to do earlier: Say, there is one Employee Class with below properties. public class Employee { private int empId; private String empName; private String gender; private String salary; // and … Continue reading Java 8 Stream APIs