I'm currently writing a little game using an 2D Array (Array of Arrays). In one of my classes which is handling the movement and placement of enemy units, there is a method that calls upon a method called "getPos" this is the Array in which the position of all enemies are stored, however I'm encountering a NullPointerException and can't for the life of me spot why it's snagging there.
Below is the code the exception is flagged, I managed to pin the error on the line
"gridPos[0][0].getType()":
public class Movement extends ArrayControl {
public Movement(Display display) {
super(display);
}
private static ArrayControl arrayControl = new ArrayControl(display);
public static void addEnemyShip(){
EnemyBehaviour[][] gridPos = display.getGridPos();
gridPos[0][0] = new Ship();
arrayControl.updatePosition(gridPos[0][0].getType(), 0, 0);
}
And this is the segment that handles the actual passing of gridPos:
public EnemyBehaviour[][] getGridPos() {
return gridPos;
}
And this is the getType() method in the super class of Ship()
public String getType() {
return type;
}