I have an int[3][3] array and it contains only 0 or 1 values, if the value is 1 I want to add the coordinates of this value in the ArrayList as int[2] array, but I don\'t know w
You need to create new coordinates
array for each i
,j
pair you want to place in your list. For now you are placing same array multiple times which remembers last set pair.
In other words you need to
if (board[i][j] == 1) {
coordinates = new int[2];//add this line
coordinates[0] = i;
coordinates[1] = j;
arrayList.add(coordinates);
}