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

Composition vs Aggregation

Kitchen in House is Composition and Engine in Car is Aggregation Composition: If internal attributes can not exist without Outer Class, that goes to Composition. You can not take Bedroom, Kitchen or Balcony out of any Flat or House. i.e Now imagine, Can we access Kitchen if we set No. It means, the attributes of House (i.e. Kitchen) Class can not exist without its House … Continue reading Composition vs Aggregation