bikasit babu wrote:why string class is final?
The most basic reason behind String class to be kept final is probably the multithreading issue. By being final,
Java maker ensured that, operation involving String class are Thread-Safe..
What I mean is that, no
Thread can pass a String object to another Thread, without building it completely.
Another reason for this may be: -
String class contains lots of methods that the Java maker didn't wanted to be modified.
Because some creepy developer might overload the String class, and provide his own implementation of some pre-defined method that can make his life hell..
For Example: -
Methods like contains(), compare(), startWith(), length(), etc,
So, if someone redefines these methodss in his own class subclassing the String class, then he can get some underiable results..
Guillaume Jourdan wrote:
String class is final because, they are immutable..
Well, actually it is other way round.. String objects are immutable because, String class is final.. And that is that Bikasut is asking... Why is that??