snipt

Ctrl+h for KB shortcuts

Java

List to Array

String[] items = list.toArray(new String[list.size()]);
https://snipt.net/embed/0a32d4c44a721ff2049673fb62713578/
/raw/0a32d4c44a721ff2049673fb62713578/
0a32d4c44a721ff2049673fb62713578
java
Java
1
2019-07-20T11:34:46
True
False
False
Oct 18, 2013 at 04:05 AM
/api/public/snipt/88445/
list-to-array-2
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">String</span><span class="o">[]</span> <span class="n">items</span> <span class="o">=</span> <span class="n">list</span><span class="o">.</span><span class="na">toArray</span><span class="o">(</span><span class="k">new</span> <span class="n">String</span><span class="o">[</span><span class="n">list</span><span class="o">.</span><span class="na">size</span><span class="o">()]);</span> </span></pre></div> </td></tr></table>
array, list, to