If i have the following code :
public static void main(String [] args) {
List l2 = new ArrayList ();
List &l
The unbounded wildcard is reifiable only in that no type information is lost at runtime because there's no type information to lose. As to your questions:
a. The test method doesn't know that l2 has Integer type. To the test method, it's a List containing "something", and that's all.
b. There's no "translation". It's just a list of unbounded type passed as a parameter to a method that takes a list of unbounded type.
I don't believe the <?>
is reified. It is simply the only way to refer to a generified type without using the raw form (List
). In both cases you are simply doing the exact same operation as:
if (l instanceof List)
...
Indeed I have just verified that they generate absolutely identical bytecode whether you use List<?>
or List
in the instanceof
.