Top Java 8 Features

  1. Default methods are declared using the new default keyword. These are accessible through the instance of the implementing class and can be overridden.

  2. Java 8 introduces an annotation known as @FunctionalInterface that is usually for compiler-level errors. It is typically used when the interface you are using violates the contracts of the functional interface.

    Alternatively, you can call a functional interface a SAM interface or a Single Abstract Method interface. A functional interface allows exactly one “abstract method” as its member.

  3. Lambda Expressions were added in Java 8.

    A lambda expression is a short block of code that takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.