I tried to create two dimensional ArrayList
i get NullPointerException
in 7 line
ArrayList<Integer>[] g = new ArrayList[500];
for(int i = 1;i < HEIGHT - 1; i++){
for(int j = 1;j < WIDTH - 1; j++){
if(MAP[i][j] == 0){
int cur = i * HEIGHT + j;
if(MAP[i+1][j] == 0){
g[cur].add(cur + HEIGHT);
}
if(MAP[i-1][j] == 0){
g[cur].add(cur - HEIGHT);
}
if(MAP[i][j+1] == 0){
g[cur].add(cur + 1);
}
if(MAP[i][j-1] == 0){
g[cur].add(cur - 1);
}
}
}
}