I have a 2d char array of a map, where each position in the array refers to the character in that position in the map. I also have the user’s current position. I have checked my map contains values and that the position is correct and that I am not trying to reach anything out of bounds in the map. For some reason my n = map[….], e =… etc isn’t working and comes back with the error ‘not a statement’ and ‘; needed’ etc. I cannot see why this would not work. Any ideas?
public String look(int[] position, char[][] mapArray)
{
char[][] map = mapArray;
char n;
char e;
char s;
char w;
int across;
int down;
across = position[0];
down = position[1];
System.out.println(across);
System.out.println(down);
n = map[(down + 1),across];
e = map[down, (across + 1)];
s = map[(down - 1), across];
w = map[down, (across - 1)];
//System.out.println("Across" + across);
//System.out.println("Down" + down);
//System.out.println("N" + n);
//System.out.println("E" + e);
//System.out.println("S" + s);
//System.out.println("W" + w);
return "hello";
}
It should be: