Проблема в том, что у меня есть кодJava. Массив объектов
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 ;
}
Он работает. Но когда я пытаюсь создать AllComponents массив [10] этого класса Component
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<nComponents;iCounter++){
AllComponents.Shifts = GetShifts(...blah-blah-bla...);
AllComponents.Couplings = GetGouplings(...blah-blah-bla...);
}
}
public Component[] AllComponents ;
}
не copmile.
Но если игнорировать construstor-х()
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<nComponents;iCounter++){
AllComponents.Shifts = GetShifts(...blah-blah-bla...);
AllComponents.Couplings = GetGouplings(...blah-blah-bla...);
}
}
public Component[] AllComponents ;
}
он не может разрешить Сдвиги и соединительные муфты в качестве полей ...
Что вы могли бы посоветовать? Примечание. GetShifts() не имеет ничего общего с getShift() для Java. Он мой, он работает хорошо, я проверил.
Thanx!
Вы не должны назвать ваши переменные, начиная с Заглавная буква. Следуйте соглашениям Java. –