https://github.com/IamPawan777/Java-8-with-Stream-API
(Functional Interface / Lambda Expression)
Has exactly single abstract method. But more than one default and static method.
**1- abstract method :** not 0-abstract method & N-abstract method
N-default method
N-static method
@FunctionalInterface
public interface Calculate {
void cal();
}
public class Main {
public static void main(String[] args) {
//1. with {}....-> when more lines
**Calculate val = () -> {**
System.out.println("Pawan Bisht");
System.out.println("Harry Doi");
System.out.println("Sam honny");
**};**
val.cal();
// 2.without {}......when one line only
**Calculate val = () -> System.out.println("Heelo Ho");**
val.cal();
}
}
@FunctionalInterface
public interface Calculate {
int cal(int a, int b);
}
public class Main {
public static void main(String[] args) {
// 3. parameterized....
**Calculate add = (a, b) -> a+b;**
System.out.println("Sum is: "+add.cal(12, 12));
}
}
Pre-define Interface: