Utilizing Generics in Inheritance and Implementation

Learn how to use generics when inheriting from open generic classes and implementing generic interfaces with explicit type argument specifications.

Type parameters and inheritance

Classes can inherit from open generic classes or implement generic interfaces; however, in both cases, they must explicitly specify the type argument. Consider the code below. Class A inherits from C<Int> and implements I<String>.

Get hands-on with 1200+ tech skills courses.