+2 votes
in JAVA by
Why is String Immutable in Java?

1 Answer

0 votes
by
One of my favorite Java interview question. The String is Immutable in java because java designer thought that string will be heavily used and making it immutable allow some optimization easy sharing same String object between multiple clients. See the link for the more detailed answer. This is a great question for Java programmers with less experience as it gives them food for thought, to think about how things works in Java, what Jave designers might have thought when they created String class etc.

Related questions

0 votes
asked Jan 24, 2020 in JAVA by rahuljain1
0 votes
asked May 3, 2021 in JAVA by Robindeniel
...