Why String is final in Java?

String class is made final to close one of the open doors which can make an immutable class mutable.

There are many chances by which an immutable class can be made mutable if it is allowed to be subclassed (i.e if it can be extended). Therefore often immutable classes are made final so that they cannot be extended, making them strongly immutable as against to weakly immutable.

Thus String is made final to make it strongly immutable.
 
Back
Top