Need Assistance?

support@tutorialshub.in

Arrays & Strings in Java

Java String Pool & Immutability

ADVERTISEMENT
Java Free Lesson
5 min read
ADVERTISEMENT

In Java, String objects are immutable—once created, their characters cannot be changed. When you write String s = "Java";, Java stores it in a special heap area called the String Constant Pool to save memory.

Interview Rule: Always compare String contents using .equals() (not ==), because == compares memory references while .equals() compares actual characters!

ADVERTISEMENT
Hi, I'm Tuby! Here to help you