Daily Archives: October 6, 2014

The String Constant Pool

String Constant Pool is possible only because String is immutable in Java and its implementation of the String interning concept. The string pool is also an example of a Flyweight design pattern. String Pool Examples Instructions So as you can see, the reference of s1, s2, s3, and s6 are the same. Actually, the object of s4 and s5 are stored in the Heap of JVM, and String Constants are stored in the Method Area of JVM. Something about intern() When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the equals(Object) method, then the string from the pool is returned. Otherwise, this String object is added to the pool,…

Continue Reading
Contact Us
  • Nanyang Technological University, Singapore
  • root [at] haozhexie [dot] com