Java 8 - Default Methods and Enhanced Stream API

In this post we'll talk about Java 8 default methods and new stream API.First let's go back and talk about how previous Java versions handled interfaces and what are the rules applied.For that we'll implement simple intrface which gives us time details. public interface TimeClient { void setDateAndTime(int day, int month, int year, int hour, int minute, int second); LocalDateTime getLocalDateTime(); } As you can see all the methods are abstract and do not have a method body.Let's implement this interface in a class and add method bodies to the methods. public class SimpleTimeClient implements TimeClient { private LocalDateTime dateAndTime; public SimpleTimeClient() { dateAndTime = LocalDateTime.now(); } public void setDateAndTime(int day, int month, int year, int hour, int minute, int second) { LocalDate dat...