Thursday, 31 July 2014

String Pool

String Pool is a pool of Strings stored in Java heap memory. We know that String is special class in java and we can create String object using new operator as well as providing values in double quotes. 

When we use double quotes to create a String, it first looks for String with same value in the String pool, if found it just returns the reference else it creates a new String in the pool and then returns the reference.

String Pool is possible only because String is immutable in Java.

No comments:

Post a Comment