-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstructorRefGen8.java
44 lines (32 loc) · 1.04 KB
/
ConstructorRefGen8.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
import java.util.List;
import java.io.Serializable;
import java.util.ArrayList;
interface ImplGen<T extends List<Object>> {
CImplGen<T> add(int a, int b);
}
interface ImplGen1<T extends List<Serializable>> {
CImplGen<T> add(int a, int b);
}
interface ImplGen2<T extends List<Number>> {
CImplGen<T> add(int a, int b);
}
interface ImplGen3<T extends List<? super Number>> {
CImplGen<T> add(int a, int b);
}
class CImplGen<T extends List<? super Number>> {
public CImplGen(int a, int b) {
System.out.println("a = " + a + " " + "b = " + b);
}
}
public class ConstructorRefGen8 {
public static void main(String[] args) {
ImplGen<ArrayList<Object>> ref = CImplGen::new;
ref.add(10, 20);
ImplGen1<ArrayList<Serializable>> ref1 = CImplGen::new;
ref1.add(10, 20);
ImplGen2<ArrayList<Number>> ref2 = CImplGen::new;
ref2.add(10, 20);
ImplGen3<ArrayList<Number>> ref3 = CImplGen::new;
ref3.add(10, 20);
}
}