I have a 2D array freeSpace[][] that represents x, y coordinates. If the space is "not free" then I have it marked as 77, other 1.
I want to put all the elements marked as 77 into it's own array, with those particular array coordinates. I think it should be simple, but I just can't get the syntax correct.
Here is my code:
for (int v = 0; v < info.getScene().getHeight(); v++) {
for (int h = 0; h < info.getScene().getWidth(); h++) {
//System.out.print(freeSpace[h][v] != 77 ? "." : "#");
if (freeSpace[h][v] == 77) {
blockedCoordinates = new int[][]{{h, v}};
}
}
System.out.println();
}
I have already declared the blockedCoordinates[][] array.
Most of my attempts have lead to an empty array.
blockedCoordinatesarray, overwriting anything previously there Can you give a small example of a grid (say, 3x3) and what you expect theblockedCoordinatesarray to look like afterwards?Additionally, for only two states, abooleanwould suffice, or better yet, anenumSo more can be added easily later.