title: How does this Java code snippet work? (String pool and reflection)
body: <p>Java string pool coupled with reflection can produce some unimaginable result in Java:</p>
  
  <pre><code>import java.lang.reflect.Field;
  
  class MessingWithString {
      public static void main (String[] args) {
          String str = "Mario";
          toLuigi(str);
          System.out.println(str + " " + "Mario");
      }
  
      public static void toLuigi(String original) {
          try {
              Field stringValue = String.class.getDeclaredField("value");
              stringValue.setAccessible(true);
              stringValue.set(original, "Luigi".toCharArray());
          } catch (Exception ex) {
              // Ignore exceptions
          }
      }
  }
  </code></pre>
  
  <p>Above code will print:</p>
  
  <pre><code>"Luigi Luigi" 
  </code></pre>
  
  <p>What happened to Mario?</p>