-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample7.java
53 lines (37 loc) · 1021 Bytes
/
Example7.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
51
52
53
import java.io.Serializable;
interface A1<T> {
public T get(T a);
}
interface B1<T> {
public T get(T b);
}
class C1<T> implements A1<T>, B1<T> {
public T get(T c) {
return c;
}
}
public class Example7<T extends A1<? super Number> & B1<? super Number>> {
public static void main(String[] args) {
A1<Number> a = new A1<Number>(){
@Override
public Number get(Number a) {
return a;
}
};
System.out.println(a.get(1));
B1<Object> b = new B1<Object>(){
@Override
public Object get(Object b) {
return b;
}
};
System.out.println(b.get(2));
B1<Serializable> b2 = new B1<Serializable>() {
@Override
public Serializable get(Serializable b) {
return b;
}
};
System.out.println(b2.get(3));
}
}