title: Can you explain the output of the following source code?
body: <p>As Strings objects are immutable in java then how for this code output is coming <code>NOW HEAT</code>, why not <code>HOW NEAT</code>?
  Thanks in advance.</p>
  
  <pre><code>class Solution
  {
     public static void main(String args[])
      {
          String[] words = {"HOW", "NEAT"};
          twist(words);
          System.out.println(words[0] + " " + words[1]);   
      }
      public static void twist(String[] w)
      {
           String temp = w[0].substring(0, 1);
           w[0] = w[1].substring(0, 1) + w[0].substring(1);
           w[1] = temp + w[1].substring(1);
      }
  }
  </code></pre>