arrays and constructors

When you declear an array of classes the default constructor is used. Is there any way not to use the default constructor while declearing an array

//eg. default constructor
myclass[] x = new myclass[5];

i want to use another constructor that myclass has.



Answer this question

arrays and constructors

  • Chimme

    thats what i thought

  • frieste

    Hi,

    You're just declaring an array of classes here. They don't get instatiated yet, so no class constructor is called... You'll have to go through the array and instatiate each class in it by calling your nondefault constructor.

    Andrej



  • arrays and constructors