0
Can i use wildCard in Type parameter reference?
Example: class A<T>{ void show(T<? >) {} } Is it valid or invalid
1 Odpowiedź
+ 2
// yes
class A<T> {
T store;
void show(A<?> a) {
System.out.println( a.store);
}
}
public class Program {
public static void main(String[] args) {
A<String> aStr = new A<>();
A<Integer> aInt = new A<>();
aInt.store = 110;
aStr.show( aInt );
}
}