what is the reason to make String class immutable.......?
Joined: Oct 13, 2005
Welcome to the Ranch.
Have you read the API documentation for String? That is so you can use the same String object in several different places. If you have a String like "Arpit" you can pass it around your application in different classes and different threads secure in the knowledge that it will still say "Arpit" when you have finished. If a String were mutable it would require a new String every time you used it, otherwise your String "Arpit" could mysteriously change to "Campbell" when you don't expect it.