I’ve seen the wildcard used before to mean any object – but recently saw a use of:
<? extends Object>
Since all objects extend Object, are these two usages synonymous?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
<?>and<? extends Object>are synonymous, as you’d expect.There are a few cases with generics where
extends Objectis not actually redundant. For example,<T extends Object & Foo>will causeTto becomeObjectunder erasure, whereas with<T extends Foo>it will becomeFoounder erasure. (This can matter if you’re trying to retain compatibility with a pre-generics API that usedObject.)Source: http://download.oracle.com/javase/tutorial/extra/generics/convert.html; it explains why the JDK’s
java.util.Collectionsclass has a method with this signature: