Why string class is immutable in java

Give me correct answer with real time example it's very Argent to me

Your Answer

Were String not immutable, a connection or file would be changed and lead to serious security threat. Mutable strings could cause security problem in Reflection too, as the parameters are strings. Efficiency The hashcode of string is frequently used in Java. For example, in a HashMap.

Core Java

Didn't get the answer.
Contact people of Talent-Core Java directly by clicking here