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

When can we say that threads are not lightweight process in java?

588


What is the use of a copy constructor?

570


What is the reason behind using constructors and destructors?

556


Why do we need singleton class?

547


What is string pooling concept?

551






What is meant by collection in java?

547


How we can skip finally block of exception even if some exception occurs in the exception block in java?

522


what is mena by object block any what is the use of that

1770


What is this keyword in java?

563


What is bool mean?

566


What are the five major types of reference sources?

533


Explain about serializable interface in java?

581


Why multiple inheritance is not supported by java?

514


Can you explain the usages of class.forname()?

606


If you do not want your class to be inherited by any other class. What would you do?

561