Saturday, December 20, 2014

String pool

As the name suggests, 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. Here is a diagram which clearly explains how String Pool is maintained in java heap space and what happens when we use different ways to create Strings.


String Pool is possible only because String is immutable in Java and it’s implementation of String interning concept. String pool is also example of Flyweight design pattern.

No comments:

Post a Comment