Internal functioning of Type Erasure in Generics
In How Generics works in Java section of this it says
Java compiler, when it sees code written using Generics it completely
erases that code
and covert it into raw type i.e. code without Generics. All type related
information is
removed during erasing. So your ArrayList<Gold> becomes plain old
ArrayList prior to
JDK 1.5, formal type parameters e.g. <K, V> or <E> gets replaced by either
Object or
Super Class of the Type.
My question is about the last line - formal type parameters e.g. <K, V> or
<E> gets replaced by either Object or Super Class of the Type.
In which case are they replaced by Object and in which case they are
replaced by the Super Class of the object type?
No comments:
Post a Comment