title: why arrays are initialized to default values but not arraylist in java?
body: <p>The implementation of <code>ArrayList</code> uses <code>Array</code> under the hood. However, <code>Arrays</code> are intialized to default values <code>(0 or null)</code> but <code>ArrayList</code> are just empty. why is this?</p>
  
  <pre><code>       int[] arr = new int[10];
         String[] arr1 = new String[11];
         System.out.println(Arrays.toString(arr));
         System.out.println(Arrays.toString(arr1));
        List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;(10);
        System.out.println(list);
  
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        [null, null, null, null, null, null, null, null, null, null, null]
        []
  </code></pre>
  
  <p>This means every time I use, <code>ArrayList</code>, I need to fill stuff in;
  I was trying the below part in my code and it was throwing <code>NoSuchElementException</code> and then I realized that it is not defaulted, where as <code>Arrays</code> do</p>
  
  <pre><code>if (list.get(i)==null){
           list.add(i,x);
    else:
          list.add(i,list.get(i)+x)
  </code></pre>
  
  <p>EDIT:</p>
  
  <pre><code>even List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;(10);
  prints [] although I initialized the size;
  </code></pre>