So, in the beginning of my java class I define globally:
static long world;
world
public static long setCell(long world, int col, int row, boolean newval){
if(col>= 0 && col<8 && row>=0 && row<8){
int bitPosition = col + 8*row;
long newWorld = PackedLong.set(world, bitPosition, newval);
System.out.println(newWorld);
world = newWorld;
System.out.println(world);
return world;
}
else{
return world;
}
}
world
PackedLong.set
world
world =0x20A0600000000000L;
System.out.println(world);
setCell(world, 1, 1, true);
System.out.println(world);
2350984558603665408
2350984558603665920
2350984558603665920
2350984558603665408
setCell
world
You have the parameter world
public static long setCell(long world, int col, int row, boolean newval)
This will hide the global variable and instead update the parameter. You should avoid names the hide other variables that are present in the same scope. Instead choose a different name for the parameter.