Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Question about Generics in Java (Super vs. Extends).?

I m reading Absolute Java 6e by Walter Savitch for reference.

Let s say that SomeClass is a class and SomeInt is a interface.

In Ch14.2, Savitch says how...

<T extends SomeClass> would only allow class types that are of or descendants of SomeClass . And <T extends SomeInt> would only allow classes that have implemented SomeInt correctly.

In chap 16.1, Savitch states that "To specify that the wildcard type be an ancestor type of some class or interface, use super rather than extends .".

I m confused here. It sounds like extends and super accomplishes the same thing in this context. What is the difference?

1 Answer

Relevance
Still have questions? Get your answers by asking now.