Ask Question
12 December, 06:57

Why is String final in Java?

+3
Answers (1)
  1. 12 December, 08:07
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers