title: Java. Array of objects
body: <p>The problem is: i have this code:</p>
  
  <pre><code>public class Component {
  public Component() {
  // TODO Auto-generated constructor stub
   }
   public double[] Shifts ;
   public double[][] Couplings ;
  
  }
  
  public class Decouplage {
   public Decouplage(double[] GroupShifts, double[][] GroupCoup) {
    AllComponents = new Component(); 
    AllComponents.Shifts = GetShifts(...blah-blah-bla...);
    AllComponents.Couplings = GetGouplings(...blah-blah-bla...);
   }
  
  public Component AllComponents ; 
  }
  </code></pre>
  
  <p>It works. 
  But when I try to create an array AllComponents[10] of this class Component </p>
  
  <pre><code> public class Decouplage {
   public Decouplage(double[] GroupShifts, double[][] GroupCoup) {
    AllComponents = new Component()[nComponents]; /////HOW MUST I PUT IN ONE LINE THE NUMBER OF ELEMENTS AND THE () FOR CONSTRUCTOR????
    for (int iCounter=0;iCounter&lt;nComponents;iCounter++){
           AllComponents.Shifts = GetShifts(...blah-blah-bla...);
           AllComponents.Couplings = GetGouplings(...blah-blah-bla...);
    }
   }
  public Component[] AllComponents ; 
  }
  </code></pre>
  
  <p>it does not compile.</p>
  
  <p>But if I ignore the constructor's () </p>
  
  <pre><code>public class Decouplage {
   public Decouplage(double[] GroupShifts, double[][] GroupCoup) {
    AllComponents = new Component[nComponents]; /////IS IT LEGAL TO IGNORE CONSTRUCTOR, EVEN IF IT IS EMPTY????
    for (int iCounter=0;iCounter&lt;nComponents;iCounter++){
           AllComponents.Shifts = GetShifts(...blah-blah-bla...);
           AllComponents.Couplings = GetGouplings(...blah-blah-bla...);
    }
   }
  public Component[] AllComponents ; 
  }
  </code></pre>
  
  <p>it can not resolve Shifts and Couplings as a fields...</p>
  
  <p>What could you advise? 
  Note: GetShifts() has nothing with a standard Java's getShift(). It is my own, it works well, i checked.</p>
  
  <p>Thanx!</p>