map = new BufferedImage[width][height];
for(int i=0;i<height;i++){
for(int j=0;j<width;j++){
if(charMap[j][i] == Mountains.indentifier) {
if ( j+1 < width && j-1 >= 0){
if(charMap[j-1][i] != Mountains.indentifier && charMap[j+1][i] != Mountains.indentifier) {
map[j][i]= tileGrid[1][10];
}
}
else {
map[j][i]= tileGrid[8][10];
}
}
}
this is the code I’m using to try to check the 2D array by checking each tile around the cell but I seem to be getting a nullpointerexception I’m wondering if anyone can help?
I am suspecting that you are getting the NullPointerException from
charMap[j][i] == Mountains.indentifierline.Make sure that you initialize inner arrays for both charMap and map as suggested by Geoff.