I am wondering why the first line compiles but the second not
new Integer(1) instanceof Comparable<?>;
new Integer(1) instanceof Comparable<Integer>;
The error msg is:
illegal generic type for instanceof
Thanks
From JLS Sec 15.20.2 :
It is a compile-time error if the ReferenceType mentioned after the instanceof operator does not denote a reference type that is reifiable (§4.7).
From Sec 4.7
A type is reifiable if and only if one of the following holds:
...
- It is a parameterized type in which all type arguments are unbounded wildcards (§4.5.1).
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.