This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes ? extends String Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "? extends String" Watch "? extends String" New topic
Author

? 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,

Suresh.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

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


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8439

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


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

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

Joined: Jul 26, 2007
Posts: 8439

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: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: ? extends String
 
Similar Threads
CertPal Question
Generics
Generics <? extends String> Question
Generics ? extends
Question in Generics -2