title: Java populate ComboBox
body: <p>I would like to populate ComboBox in Java, but:</p>
  
  <ul>
  <li>when I use array of strings, I must define the size of array before (this is disadvantage),</li>
  <li>when I would like to use ArrayList, I cant have empty items with null values or I cant skip ids:</li>
  </ul>
  
  <pre class="lang-java prettyprint-override"><code>        ArrayList&lt;String&gt; a = new ArrayList&lt;String&gt;();
          a.add(0, "hahah");
          a.add(1, "bleeeee");
          a.add(5, "cleeeee"); //this makes an error, when I change index to 2, it works
  
         JComboBox supplierComboBox = new JComboBox(a.toArray());
  </code></pre>
  
  <p>My array is for example:</p>
  
  <pre class="lang-php prettyprint-override"><code>[1] =&gt; "dog",
  [5] =&gt; "mouse",
  [8] =&gt; "cat".
  (some ids missing).
  </code></pre>
  
  <p>THX.</p>