title: Can I declare and initialize an array with the same instruction in Java?
body: <p>Is there a way to do the following at the same time?</p>
  
  <pre><code>static final int UN = 0; // uninitialized nodes
  int[] arr;
  
  // ... code ...
  
  arr = new int[size];
  for (int i = 0; i &lt; 5; i++) {
      arr[i] = UN;
  }
  </code></pre>
  
  <p>Basically, I want to declare <code>arr</code> once I know what its size will be and initialize it to <code>UN</code> without having to loop. So something like this:</p>
  
  <pre><code>int[] arr = new int[size] = UN;
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p>Thanks.</p>