0

Can i use wildCard in Type parameter reference?

Example: class A<T>{ void show(T<? >) {} } Is it valid or invalid

2nd Jul 2021, 4:27 PM
Jawahirullah
Jawahirullah - avatar
1 Réponse
+ 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 ); } }
2nd Jul 2021, 4:49 PM
zemiak