Consider the follow code for Generic. Because of erasure property I defined the methods differently.
However since the compiler erases the generics these classes will not carry this information forward so does this mean if packaged in a jar I will not be able to call these methods. I know that in real world scenario I am still able to call and get good results but how is "type erasure" effective if this information is deleted during compilation yet when it is required at runtime.
SCJP 1.4 90%, SCWCD5 94%, Next SCDJWS--> In Naescent stage. Researching abt exam and material itself.
Kamal Tripathi wrote:how is "type erasure" effective...
Type erasure is effective at allowing us to mix legacy code with generics code, however, due to the design of your code, mixing legacy code with generics code will lead to an 'ambiguity' compiler error.
Kamal Tripathi wrote:...when it is required at runtime
It is not required at runtime. At compile time, the compiler removes all information related to type parameters and type arguments. It is able to do this because this information is not required at runtime. At compile time, the compiler decides which overloaded method will be called.