<p>Assuming I have an ArrayList</p>

<pre><code>ArrayList&lt;MyClass&gt; myList;
</code></pre>

<p>And I want to call toArray, is there a performance reason to use</p>

<pre><code>MyClass[] arr = myList.toArray(new MyClass[myList.size()]);
</code></pre>

<p>over</p>

<pre><code>MyClass[] arr = myList.toArray(new MyClass[0]);
</code></pre>

<p>?</p>

<p>I prefer the second style, since it's less verbose, and I assumed that the compiler will make sure the empty array doesn't really get created, but I've been wondering if that's true.</p>

<p>Of course, in 99% of the cases it doesn't make a difference one way or the other, but I'd like to keep a consistent style between my normal code and my optimized inner loops...</p>

Using 'toArray' with the array of the correct size will perform better as the alternative will create first the zero sized array then the array of the correct size. However, as you say the difference is likely to be negligible.
Also, note that the javac compiler does not perform any optimization. These days all optimizations are performed by the JIT/HotSpot compilers at runtime. I am not aware of any optimizations around 'toArray' in any JVMs.
The answer to your question, then, is largely a matter of style but for consistency's sake should form part of any coding standards you adhere to (whether documented or otherwise).