Ask Question
13 January, 01:34

Why is String final in Java?

+1
Answers (1)
  1. 13 January, 02:02
    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?
Find an answer to your question 👍 “Why is String final in Java? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers