Can i use wildCard in Type parameter reference? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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 Answer
+ 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