Thursday, October 28, 2021

Java 8 in action

 Functional interfaces: Interfaces which define exactly one abstract method. They can be used by Lambdas to instantiate an object of that type with the abstract method implemented.

For e.g. 

Runnable r1 = () -> {System.out.println("Hello world 1");}

process(r1); //prints Hello world 1

Runnable is an interface with exactly one abstract method named "run";

OR

process(() -> System.out.println("This is awesome!!"));

------------------------------------------------------------



Blog Archive