Why string is immutable in java?
Manohar Posted new comment November 13, 2019
- String pool is possible only because String is immutable in Java.
- This way Java Runtime frees a lot of heap space because different String variables can refer to the same string variable in the pool.
- If String not have been immutable, then String interning not have been possible because if any variable has changed the value, it has been reflected in the other variables too.
Manohar Changed status to publish November 13, 2019
[…] Read : Why string is immutable in java? […]