What happens to casts using generics - (T)object - at run-time in Java?
问题 As far as I understand, Java Generics erases all the information concerning the parameter type T in the generic method (or in the generic class). That's why we can't use new expression, such as new T() instanceof expression, such as if(obj instanceof T) inside a generic method. My question is how the parameter type T works inside a generic method when it comes to casting. For example, I have 3 simple classes here: public class People { String name; public String getName() { return name; }