【发布时间】:2012-05-09 16:15:48
【问题描述】:
我似乎无法弄清楚这一点,如果你们能帮助我,那就太棒了! 我正在尝试将已创建的对象传递给构造函数,以便获取它们的所有值。
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 都是数组。
提前感谢您!
【问题讨论】:
标签: java android arrays nullpointerexception