title: strange java string array null pointer exception
body: <p>This problem came up in a practice test:  create a new string array, initialize it to null, then initializing the first element and printing it.  Why does this result in a null pointer exception?  Why doesn't it print "one"?   Is it something to do with string immutability?   </p>
  
  <pre><code>public static void main(String args[]) {
          try {
              String arr[] = new String[10];
              arr = null;
              arr[0] = "one";
              System.out.print(arr[0]);
          } catch(NullPointerException nex) { 
              System.out.print("null pointer exception"); 
          } catch(Exception ex) {
              System.out.print("exception");
          }
      }
  </code></pre>
  
  <p>Thanks!</p>