Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The difference between "instanceof List" and 'o instanceof List<?>"

I don't see any difference in the following:

    Object o = new LinkedList<Long>();

    System.out.println(o instanceof List); 
    System.out.println(o instanceof List<?>);

Is there any practical use of instanceof List<?> when instanceof List can't be used instead and vise versa?

like image 645
andrii Avatar asked Dec 16 '22 13:12

andrii


1 Answers

No difference. The wildcard is erased at compile time.

like image 83
Bozho Avatar answered Mar 08 '23 08:03

Bozho