Inheritance Rules for Generic Types

Java-Inheritance Rules for Generic Types

Inheritance Rules for Generic Types When you work with generic classes, you need to learn a few rules about inheritance and subtypes. Consider the following classes and statements : The class ComputerStudent is a subclass of class Student. Is MyClass<ComputerStudent> a subclass of MyClass<Student>? Perhaps surprisingly, the answer is “no.” The third statement will not compile and it … Read more…