Register now or log in to join your professional community.
Making the class final prevents subclasses that could break
final is used by the class loading mechanism....It profound fundamental security aspects
Because it is used by the class loading mechanism.
string is immutable.once we instalizeed we can not change its value.
It is immutable objects, Ther are many advantages of immutable objects as you can share duplicates by pointing them to a single instance.
java string is the core class anad String class is immutable in Java, The string pool was possible only if the string is made final. As if some variable is referring to String pool's object and somehow it gets modified, then it will lead to a failure.
The one reason is all the inputs are get in only the Strings. The String is immutable.
The another reason is security and performance. Once we initialize the string is we cannot change the value.
it is used by the class loading mechanism, and thus have profound and fundamental security aspects.string is a very core class in java
Requirement of String Pool, Caching Hashcode, Facilitating the Use of Other Objects, Security, Immutable objects are naturally thread-safe