title: Java - allocation in enhanced for loop
body: <p>I have small problem in java with allocation of my object in "enhanced for loop".
  I tried something like this, which gives me later nullPointerException:</p>
  
  <pre><code>SomeClass tab[] = new SomeClass[100];
  for( SomeClass x : tab){
    x = new SomeClass();
  }
  </code></pre>
  
  <p>So... Earlier I code in C++ and It was possible to edit in any way (and sure also allocate memory) object, when just add &amp; operator, like this:</p>
  
  <pre><code>SomeClass *tab = new SomeClass[100];
  for( auto &amp; x : tab){
    x = new SomeClass();
  }
  </code></pre>
  
  <p>...and everything works well. But how is it in java? Is there any way to use this for loop when allocate some memory or not?</p>