The idea is to make your black and white fields dependent of both of your for-loop counters.
for(int i =0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if( (i+j) % 2 == 0){
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println("");
}
or switch the " "
and "*"
to let your chessboard start with a white field in the upper left corner.
1
solved Simple Chessboard in java