-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMethodRefGen3.java
50 lines (33 loc) · 1.19 KB
/
MethodRefGen3.java
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
41
42
43
44
45
46
47
48
49
50
interface MethodRefAdd2<T> {
int add(int a, int b);
}
interface MethodRefAdd3<T> {
int add(int a, int b);
}
class MethodRefAddGen3<T> {
static int add(int a, int b) {
return a + b;
}
}
public class MethodRefGen3<T extends MethodRefAdd2<Number> & MethodRefAdd3<Number>> {
static int add(int a, int b) {
return a + b;
}
static int Add(MethodRefAdd2<Number> a, int b, int c) {
return a.add(b, c);
}
public static void main(String[] args) {
MethodRefAdd2<Number> a = Integer::sum;
int res = a.add(12, 13);
System.out.println(res);
MethodRefAdd2<Number> a1 = MethodRefAddGen3::add;
int res1 = a1.add(12, 13);
System.out.println(res1);
Integer sum = Add(Integer::sum, 12, 13);
System.out.println(sum);
Integer sum2 = Add(MethodRefGen3::add, 12, 13);
System.out.println(sum2);
Integer sum3 = Add(MethodRefAddGen3::add, 12, 13);
System.out.println(sum3);
}
}