+1 vote
in JAVA by
Why String is immutable or final in Java

1 Answer

0 votes
by

There are several benefits of String because it’s immutable and final.

String Pool is possible because String is immutable in java.

It increases security because any hacker can’t change its value and it’s used for storing sensitive information such as database username, password etc.

Since String is immutable, it’s safe to use in multi-threading and we don’t need any synchronization.

Strings are used in java classloader and immutability provides security that correct class is getting loaded by Classloader.

Related questions

+1 vote
asked May 3, 2021 in JAVA by Robindeniel
+2 votes
asked May 4, 2021 in JAVA by SakshiSharma
...