aspose file tools*
The moose likes Beginning Java and the fly likes Why String class is final Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why String class is final" Watch "Why String class is final" New topic
Author

Why String class is final

Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
Hi,
Why the String class is made final. Is there any specific reason why its restricted from allowing other class to subclass it ?
Hari
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
One reason may be that String is immutable, and it isn't a good idea to have mutable subclasses of String being passed around, used as hash keys, etc.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
Go to: http://www.coderanch.com/t/369875/java/java/why-String-final


SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why String class is final