title: What is the default initialization of an array in Java?
body: <p>So I'm declaring and initializing an int array:</p>
  
  <pre><code>static final int UN = 0;
  int[] arr = new int[size];
  for (int i = 0; i &lt; size; i++) {
      arr[i] = UN;
  }
  </code></pre>
  
  <p>Say I do this instead... </p>
  
  <pre><code>int[] arr = new int[5];
  System.out.println(arr[0]);
  </code></pre>
  
  <p>... <code>0</code> will print to standard out. Also, if I do this:</p>
  
  <pre><code>static final int UN = 0;
  int[] arr = new int[5];
  System.out.println(arr[0]==UN);
  </code></pre>
  
  <p>... <code>true</code> will print to standard out. So how is Java initializing my array by default? Is it safe to assume that the default initialization is setting the array indices to <code>0</code> which would mean I don't have to loop through the array and initialize it? </p>
  
  <p>Thanks.</p>