Category: JAVA STRING INTERVIEW QUESTIONS AND ANSWERS

Java String Pool is a special memory area inside the heap memory that stores unique string objects . Whenever JVM finds a String literal , it first checks whether an identical string already exists in the String constant pool . If the string is already present in the String Constant Pool, then JVM reuses the existing String object reference . If the string is not present in the String constant pool , it creates a new string object in the String Constant Pool .

The main advantages of String Constant Pool is that it reduces the memory consumption by reusing immutable string objects .

Leave a Reply

Your email address will not be published. Required fields are marked *