File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes ? extends String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "? extends String" Watch "? extends String" New topic

? extends String

Suresh Rajadurai
Ranch Hand

Joined: Feb 22, 2007
Posts: 58
25th Jan 2009.

Hi Folks,

I have a question,

Since String class is the final class , why should the following code compile. I was expecting that this would give compilation error:

Thanks & regards,

Rob Spoor

Joined: Oct 27, 2005
Posts: 19847

Because ? extends String also matches String itself. But you are quite right, the wildcard is completely useless here.

How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10567

Somewhat off topic.
Whats with the date in your post?

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jitesh Sinha
Ranch Hand

Joined: Jun 19, 2004
Posts: 146
What about it?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10567

When you post, the forum automatically records and displays the time stamp. On this background I was plain curious, thats all.
I agree. Here's the link:
subject: ? extends String