Problem with if statement
I am having trouble at an if statement within chess game I am designing for java. Basically, when a JButton square is pressed, it takes the piece at that location, followed by a second press that places the piece at that location.
The method takes the command, parses a few ints from it and passes along to check for the piece at that location. This works just fine without the if statement I added.
The if statement takes the actionCommand from the button and checks to make sure that the piece being picked up is ok for the current turn. If turn is true, it's black's turn. If false, white's. The string at the square in rules class holds a string. I am grabbing the first letter (B or W) and checking that against turn. On the second click (the piece destination, numberOfClicks == 2) I do not need it to check this however, hence the OR numberOfClicks == 2.
if(((r.square[ifCheckX][ifCheckY].substring(0,1).equals("B") && r.turn == true) || (r.square[ifCheckX][ifCheckY].substring(0,1).equals("W") && r.turn == false)) || this.numberOfClicks == 2)
It compiles fine. The first click works fine. The second click throws some nullPointerException, as a result of 2 dozen errors within other classes within java.
What is wrong with this If statement?