Ask Question
4 September, 21:57

Why is String final in Java?

+3
Answers (1)
  1. 5 September, 00:03
    0
    string objects are cached in string pool.

    Explanation:

    Strings in Java are immutable or final because the string objects are cached in String Pool. As we know multiple clients share the string literals so there exists a risk of one client's action affecting all other clients.

    For ex:-The value of string is "Roast" and client changed it to "ROAST" so all other clients will see ROAST instead of Roast.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Why is String final in Java? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers