aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes <T extends String> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "<T extends String>" Watch "<T extends String>" New topic
Author

<T extends String>

Heba Mahmoud
Ranch Hand

Joined: Apr 26, 2009
Posts: 62


how this don't cause complair error although the String class is final and can't be exteneded.
as what happens when when say



SCJP Pass 85%....
Thousands of candles can be lighted from a single candle, and the life of the candle will not be shortened
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

You are not extending string there. The construct simply means the generic type can be anything that extends String. Of course String is final and nothing can extend it.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18853
    
  40

Also, T can also be String -- and so since String is a final class, it can only be String.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: <T extends String>