If I have a subclass which extends MySuperClass and I have the following generic class:
public class GenericClass<M extends MySuperClass>{
public void aMethod(M m);
}
public class SubClass1 extends MySuperClass{}
then I do:
SubClass1 sc1 = new SubClass1();
GenericClass<MySuperClass> msc = new GenericClass<MySuperClass>();
msc.aMethod(sc1);
is is type erasure which determines whether the parametized type is legal? I presume the compiler can look at M extends MySuperClass, look at and determine its legal- but I wasnt sure if type erasure handled this?
Type erasure refers to the fact that the generic type parameters and instantiations are removed after the compilation. The compiler checks the types at compile time and then deletes all the type parameters.