This issue arose when I changed all my variables to be stored into an int[][]
. I have an object. Every time I click a button I create a new object which has its own variables. The problem is that I decided to store all the int
variables in an int[][]
and now every object that I created uses the same int[][]
grid. So I'm not sure what I may be doing wrong here.
I have tried initiating the array int[][]
within the object constructor and outside the constructor i.e. public static int[][] grid;
and then initiate it inside the constructor or I've initiated it within the constructor as int[][] grid = new int[20][20]
.
Any ideas as to why this is happening? Before I had a specific String
variable to hold that int
value but when I changed it everything to be stored in a int[][]
all the new objects I create use the same grid.