What is the difference between ‘super’ and ‘extends’ in Java Generics [duplicate]

It depends which way on the inheritance hierarchy it allows. Assume you have a class “Child” which inherits from “Parent” which inherits from “Grandparent”.

<T extends Parent> accepts either Parent or Child while <T super Parent> accepts either Parent or Grandparent.

Leave a Comment