title: Dynamically create new objects in java
body: <p>I want to dynamically create objects of a class using an array.
  This is what i have so far: </p>
  
  <pre><code>int[] n = new int[10];
  
  for (int i = 1; i &lt; 5; i++) {
    MyClass n[i] = new MyClass();
    n[i].setNumber(i);
    n[i].printNumber();
  }
  </code></pre>
  
  <p>The class MyClass conatins the constructor for MyClass and methods for set and print.</p>