Java Generics - What's really in a unbounded wildcard?

后端 未结 2 1571

If i have the following code :

public static void main(String [] args) {  
        List  l2 = new ArrayList ();  
        List &l         


        
2条回答
  •  渐次进展
    2021-01-23 06:47

    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) 
       ...
    

    Edit

    Indeed I have just verified that they generate absolutely identical bytecode whether you use List or List in the instanceof.

提交回复
热议问题