Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Why String is Immutable in java?

user-image
Question added by Muhammed Rashik
Date Posted: 2013/03/07
Zaid Rabab'a
by Zaid Rabab'a , Software Development Team Leader , Al-Safa Co. Ltd.

imagine StringPool facility without making string immutable , its not possible at all because in case of string pool one string object/literal e.g.
"Test" has referenced by many reference variables , so if any one of them change the value others will be automatically gets affected i.e.
lets say String A = "Test" String B = "Test" Now String B called "Test".toUpperCase() which change the same object into "TEST" , so A will also be "TEST" which is not desirable.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.