Category: Java 8 features

Java 8: forEach loop

Before you start to learn this Java 8 feature, I would recommend you first to read the feature Lambda expressions. Example 1: forEach loop using lambda expression What is written to the standard output as the result of executing the following code? Author: Sar Maroof Answer explanation The answer is: Porsche Ferrari Bugatti Mercedes-Benz Lamborghini

Java 8: Default methods

The feature default methods is included in JSE8. This feature allows you to add new defalut methods to your interfaces and ensure that the classes, which implement the interface remain compatible with the new code. It is not mandatory to override default methods unlike abstract methods. For more info click here to read Oracle’s explanation. Example 1: Default […]

Java 8: Method references

The feature method references is included in JSE8. The lambda expression is used sometimes to create anonymous methods. When a lambda expression only invoke an existing method, it is better to refer the method by using its name. For more info click here to read Oracle’s explanation. Kinds of method references Reference to a static method: […]

Java 8: Lambda expressions

Lambda expression is included in JSE8. It provides implementation of a functional interface, which is an interface that contains only one abstract method, but it may contain one or more default methods or static methods. This new feature is important, because it helps to write less code by programming. For more info click here to […]