title: How does java implement flyweight pattern for string under the hood?
body: <p>If you have two instances of a String, and they are equal, in Java they will share the same memory. How is this implemented under the hood?</p>
  
  <p>EDIT: My application uses a large number of String objects, many of which are identical. What is the best way to make use of Java String constant pool, as to avoid creating custom flyweight implementation?</p>