Skip to main content
Make generics in quote visible with code formatting.
Source Link
rgettman
  • 178.7k
  • 30
  • 282
  • 365

When using generics, the inheritance concept is little bit different. You need to use wildcards and sub typing to achieve inheritance with generics.

As per oracle tutorial

Note: Given two concrete types A and B (for example, Number and Integer), MyClassMyClass<A> has no relationship to MyClassMyClass<B>, regardless of whether or not A and B are related. The common parent of MyClassMyClass<A> and MyClassMyClass<B> is Object.

When using generics inheritance concept is little bit different. You need to use wildcards and sub typing to achieve inheritance with generics.

As per oracle tutorial

Note: Given two concrete types A and B (for example, Number and Integer), MyClass has no relationship to MyClass, regardless of whether or not A and B are related. The common parent of MyClass and MyClass is Object.

When using generics, the inheritance concept is little bit different. You need to use wildcards and sub typing to achieve inheritance with generics.

As per oracle tutorial

Note: Given two concrete types A and B (for example, Number and Integer), MyClass<A> has no relationship to MyClass<B>, regardless of whether or not A and B are related. The common parent of MyClass<A> and MyClass<B> is Object.

Source Link
kosa
  • 66.7k
  • 15
  • 134
  • 170

When using generics inheritance concept is little bit different. You need to use wildcards and sub typing to achieve inheritance with generics.

As per oracle tutorial

Note: Given two concrete types A and B (for example, Number and Integer), MyClass has no relationship to MyClass, regardless of whether or not A and B are related. The common parent of MyClass and MyClass is Object.