title: Why is int[] a = new int[0]; allowed?
body: <p>Is there a reason why</p>
  
  <pre><code>int[] myArray = new int[0];
  </code></pre>
  
  <p>compiles? </p>
  
  <p><strong>Is there any use of such an expression?</strong></p>
  
  <pre><code>myArray[0] = 1;
  </code></pre>
  
  <p>gives <code>java.lang.ArrayIndexOutOfBoundsException</code>.</p>
  
  <pre><code>if (myArray == null) {
      System.out.println("myArray is null.");
  } else {
      System.out.println("myArray is not null.");
  }
  </code></pre>
  
  <p>gives <code>myArray is not null.</code>.</p>
  
  <p>So I can't see a reason why <code>int[] myArray = new int[0]</code> should be preferred over <code>myArray = null;</code>.</p>