After some research I have come to know that generics are a compile time type check feature. They are used to ensure that incorrect types are not used and after that additionally the parameterised type information is also removed to avoid unnecessary overhead at runtime. This process of removing the paramterized type information at compile is known as type erasure.
I would also like to clarify how generics actually ensure that incompatible types are not used. Is this done by inserting necessary typecasts at compile time which result in compiler errors when an invalid type is met? But isn't it true that typecasts are used for runtime checking? If so, how does the compiler prevent invalid types at compile time?
Okay, I should have come to realise that the typecasting that automatically occurs at compile time to prevent incompatible types is actually implicit and internal. And so it is different to the typecasting which I was referring to in the latter part my question, which is a runtime check feature. So there is no conflict.