forked from Java-Techie-jt/java8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculatorImpl.java
More file actions
39 lines (28 loc) · 709 Bytes
/
Copy pathCalculatorImpl.java
File metadata and controls
39 lines (28 loc) · 709 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
package com.javatechie.lambda.demo;
interface Calculator {
// void switchOn();
/* void sum(int input); */
int substract(int i1, int i2);
}
public class CalculatorImpl {
public static void main(String[] args) {
/*
* Calculator calculator = () -> System.out.println("Switch On");
*
* calculator.switchOn();
*/
/*
* Calculator calculator = (input) -> System.out.println("Sum : " + input);
* calculator.sum(394);
*/
Calculator calculator = (i1, i2) -> {
if (i2 < i1) {
throw new RuntimeException("message");
} else {
return i2 - i1;
}
};
System.out.println(calculator.substract(8, 20));
}
// () -> {body};
}