title: Java ArrayList clear() function
body: <p>Let's say I have a <code>ArrayList&lt;String&gt; data;</code></p>
  
  <p>I'm adding some data into this Array, using <code>data.add()</code> function.
  Let's say I've added 10 Strings into this array. The size of the array is 10 now.</p>
  
  <p>How do i destroy all elements in the array? The <code>data.clear()</code> function just set's all 10 elements to null. So when I try to add another element, it just get's on the 11 position. I want just to start it over from 0;</p>
  
  <p>I can use a for loop to replace all the data, but I really think there is a way just to empty the <code>ArrayList</code>. Is it?</p>