Strings in java language
Ratik Mahajan
Posted on February 21, 2024
Java strings
- Java Strings are array of characters.
- Java Strings are immutable : which means once Strings are created in the String pool they can't be changed.
- Strings were earlier stored in Permgen and from java 7 onwards strings in java are stored in the heap. this makes string available for the garbage collection if it is not referenced anywhere in the memory.
- Strings in java are created through new keyword and java String literals. Strings created through new keyword are stored in heap and Strings created through literals are stored in the string pool(heap) from java 7 onwards. String pool would mean intern of the string.
Why do we intern Strings in java
- This reduces the memory footprint of string in java.
💖 💪 🙅 🚩
Ratik Mahajan
Posted on February 21, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.