title: Dynamic array in java
body: <p>What i am trying to do is</p>
  
  <pre><code>...
  int sum[];
  ...
  for(int z.....){
     ...
     sum[z] = some_random_value;
     ...
  }
  </code></pre>
  
  <p>But it gives an error at line <code>sum[z]=ran;</code> that variable <code>sum</code> might not have been initialized.</p>
  
  <p>I tried <code>int sum[] = 0;</code> instead of <code>int sum[];</code> but even that gave an error.
  (I am basically a C programmer)</p>