title: Initialize an arrayList with zeros
body: <p>I am creating an <code>ArrayList</code> and its size is <code>40</code> </p>
  
  <pre><code>ArrayList&lt;Integer&gt; myList= new ArrayList&lt;&gt;(40);
  </code></pre>
  
  <p>How can I initialize <code>myList</code> with zeros <code>0</code> ? I tried this</p>
  
  <pre><code>for(int i=0; i&lt;40; i++){
     myList.set(i, 0);
  }
  </code></pre>
  
  <p>but I get  </p>
  
  <pre><code>java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  </code></pre>