-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestType.java
More file actions
executable file
·29 lines (24 loc) · 952 Bytes
/
Copy pathTestType.java
File metadata and controls
executable file
·29 lines (24 loc) · 952 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
package lambda;
/**
* Created by gaurav on 15/9/17.
*/
class TestType {
// #2 Method parameter is of type IsTypeOne
public void first( IsTypeOne one ){
//#5 Method that is overridden by Lambda will be called.
one.hasOne();
}
//#6 Method parameter is of type IsTypeTwo
public void second( IsTypeTwo two ){
//#9 Method that is overridden by Lambda will be called.
two.hasTwo();
}
public void invoke() {
//#3 Here labmda type is "IsTypeOne", because first() has parameter of type "IsTypeOne"
//#4 Body {...} of lambda is body part of Overridden hasOne method.
first(() -> { System.out.println("Invoking first."); });
//#7 Here labmda type is "IsTypeTwo", because second() has parameter of type "IsTypeTwo"
//#8 Body {...} of lambda is body part of Overridden hasTwo method.
second(() -> { System.out.println("Invoking second."); });
}
}