我似乎无法弄清楚这一点,如果你们能帮助我,那就太棒了!我正在尝试将已经制作的对象传递给构造函数,以便获取它们的所有值。
public class Drops {
Ship ship;
Bullet[] bullet;
Aliens[] aliens;
Movement movement;
public Drops(Ship ship,Bullet[] bull,Aliens[] alienT) {
this.ship = ship;
for (int a = 0; a < MainGamePanel.maxAliens;a++) {
System.out.println(a +" " +alienT[a].x); // THIS WORKS, when nothing
// is being assigned, so the values
// are being passed correctly.
this.aliens[a] = alienT[a];
for (int b = 0; b < MainGamePanel.maxShots;b++){
this.bullet[b] = bull[b];
}
}
}
// that is is the class, and also where the error occurs
主要是我像这样将值发送给构造函数
drop = new Drops(ship, bull, alienT);
ship 不是数组 bull,alienT 都是数组。
先感谢您!