Why are strings immutable in Java?

Answer Posted / hrindows@gmail.com

Strings in java are frequently used for hashmap keys. Now if someone changes the value of the string it will cause severe discrepancies. Hence strings are made immutable.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does a cookie work in Servlets?

571


What are anonymous inner classes?

743


What does java edition mean?

744


How to remove the trailing spaces from a string?

877


What is linked hashset and its features?

725


What is singleton class example?

786


how we can use debug in myeclipse 6.0 in order solve the problems that exist in our program when there are 900 to 1000 pages in a web application

1870


Is age discrete or continuous?

868


Will the jvm load the package twice at runtime?

816


What modifiers are allowed for methods in an interface?

868


Can we force garbage collector to run ?

771


Can subclass overriding method declare an exception if parent class method doesn't throw an exception?

741


What do you mean by stack?

868


What is function and its uses?

776


What purpose do the keywords final, finally, and finalize fulfill?

853