Generics was added to provide type-checking at compile time and it has no use at run time, so java compiler uses type erasure feature to remove all the generics type checking code in byte code and insert type-casting if necessary. Type erasure ensures that no new classes are created for parameterized types; consequently, generics incur no runtime overhead.
The following program shows how the ensure works
Type Erasure CODE class GenericsErasureDemo OUTPUT GenericsErasure DESCRIPTION Here, the types of THINGS TO TRY
|