What are the disadvantages of a String?
I can share string with multiple threads, so that all threads can read it with out modifying it.
If I want to do too many modifications on string, it is not recommended to use as it generates separate object each time I try to modify it.
Strings when stored in string constant pool, uses memory efficiently due to its reusability property.
I can't inherit String class to my own class and modify its behavior.
The major disadvantage of String class is, you can't modify it, with in the same location. It generates too many objects in heap and wastes your memory if you try to modify it too many times.
So if you want to do many modifications to your string, don't use strings.
Back To Top