This is back to the beginning of Java 101, but I have this code here:
if ((d==3)&&(City.walls[x--][y])){
System.out.println ("Fourth Condition true");
System.out.println (City.walls[x--][y]);
return false;
}
Even if City.walls[x--][y]) is false, and System.out.println confirms this by printing out false, it will still enter the if statement, no matter what. What am I doing wrong with the comparison? Thanks in advance.
You are using x–, which changes the value of x. First it returns the value, then it decrements the value:
You probably want to say x-1