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 Why String class is final Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why String class is final" Watch "Why String class is final" New topic

Why String class is final

Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
Why the String class is made final. Is there any specific reason why its restricted from allowing other class to subclass it ?
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:

SCJP 1.4<br /><a href="" target="_blank" rel="nofollow"></a>
It is sorta covered in the JavaRanch Style Guide.
subject: Why String class is final
It's not a secret anymore!