Hi Debasmita,
It is called type erasure. Compiler removes all the type information from
the code before compilation is done. The type information that you study
under generics is only to restrict the programmer to not be able to do
unsafe operations.
For example, the parameterized type List<
String> is translated to type
List, which is called raw type. The same happens for the parameterized type
List<Double>; it also appears as List in the byte code.
After translation by type erasure, all information regarding type parameters
and type arguments has disappeared. As a result, all instantiations of the
same generic type share the same runtime type, namely the raw type.
Example (printing the runtime type of two parameterized types):
prints: runtime type of ArrayList<String>: class
java.util.ArrayList runtime type of ArrayList<Double> : class java.util.ArrayList
Thanks,