If i have the following code :
public static void main(String [] args) {
List <Integer> l2 = new ArrayList <Integer>();
List <?> l3 = l2;
test(l2);
test(l3);
}
public static void test(List <?> l) {
if (l instanceof List<?>)
System.out.println("true");
}
This will print:
true
true
From what i understand, <?>
is a reifiable type, which means it has some capture type (whatever that type is) which is available at run time.
Questions:
a. In test method, does it know that l2 has integer type (since it has been erased prior to the method call)? How does it translate so that l (from l2) is instanceof List <?>?
b. What about l3? How does it translate that?