1package com.concretepage;
2
3@FunctionalInterface
4public interface Calculator {
5 long calculate(long num1, long num2);
6}
1@FunctionalInterface
2interface Square
3{
4 int calculate(int x);
5}
6
7class Test
8{
9 public static void main(String args[])
10 {
11 int a = 5;
12
13 // lambda expression to define the calculate method
14 Square s = (int x)->x*x;
15
16 // parameter passed and return type must be
17 // same as defined in the prototype
18 int ans = s.calculate(a);
19 System.out.println(ans);
20 }
21}
1Supplier () -> x
2Consumer x -> ()
3Callable () -> x throws ex
4Runnable () -> ()
5Function x -> y
6BiFunction x,y -> z
7Predicate x -> boolean
8UnaryOperator x1 -> x2
9BinaryOperator x1,x2 -> x3
10