Suppose I have the following class:
class Box<T> {
public Box(T value) {
this.value = value;
}
public T value;
}
Why can’t I do this:
Object obj = new Object();
boolean isBox = obj instanceof Box<Object>;
| Error:
| java.lang.Object cannot be safely cast to Box<java.lang.Object>
| boolean isBox = obj instanceof Box<Object>;
| ^-^
But I can do this:
Object obj = new Object();
boolean isBox = obj instanceof Box<?>;