-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFunctionalInterface.java
More file actions
40 lines (31 loc) · 997 Bytes
/
FunctionalInterface.java
File metadata and controls
40 lines (31 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
interface Food //When an interface will have exactly 1 abstract method we can say it as a Functional Interface
{
void OrderFood(); // -> by default public abstract void OrderFood();
}
// class Zomato implements Food{
// public void OrderFood() {
// System.out.println("Order placed !! Arriving Soon !!");
// }
// }
public class FunctionalInterface {
public static void main(String[] args) {
//1.
// Food food = new Zomato(); // Polymorphic statement
// food.OrderFood();
//2.
// Anonymous Class Implementation
// Food food = new Food() {
// @Override
// public void OrderFood() {
// System.out.println("Order placed !! Arriving Soon !!");
// }
// };
// food.OrderFood();
//3.
Food food = () -> // Function Implementation with lambda function
{
System.out.println("Order placed !! Arriving Soon !!");
};
food.OrderFood();
}
}