I have this while loop:
//All of this code is inside a for loop
positionUp = i - 1;
while ((positionUp > 0) && boardMatrix[positionUp][j] == boardMatrix[i][j]) {
//do something
positionUp--;
}
At some point, it is possible that positionUp it's assigned with the value -1 (when i=0)
I thought that the whileloop will stop at the first falseevaluation thus not evaluating boardMatrix[positionUp][j] and not getting java.lang.ArrayIndexOutOfBoundsException: -1
I'm not seeing how can I solve this. Can someone point me in the way?