| Author |
Generics allows extending String class
|
Akshay Sahu
Greenhorn
Joined: Sep 04, 2009
Posts: 26
|
|
Hi,
If I write
Class TestGeneric<E extends String> {}
The compiler allows me to compile this. This shouldn't be allowed as final classes can neither be extended nor can be implemented.
I just want to know why is the compiler allowing that syntax to be valid.
Thanks and Regards,
Akshay Sahu
|
Akshay Sahu
OCBCD (EJB 3), OCJP (Java SE 6), MCTS (MS SQL Server 2005)
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
I don't agree that it shouldn't be allowed. Sure, the only value you can use for E is String itself, but writing a language specification which disallows that is really a waste of time. It just makes things more complicated, which means harder to test and more likely to have bugs.
|
 |
 |
|
|
subject: Generics allows extending String class
|
|
|