I wish to understand this concept:
T
object - generic, will be erased into actual type.?
object - will be erased into what?Object
object;
What are the differences between T
, ?
and Object
?
I can easily understand #1, but what about:
Object var;
? var;
What is the difference between the two? I have read that I can't use ?
explicitly, like T
or any other variable, and that ?
is related to objects, not types.
But what is the practical reason? Why can't I just write a List
of objects (List<Object>
) instead of a List
of wildcards (List<?>
)? As I don't know the types of objects on both cases.
In addition, I would like to know what is the erasure for ?
?