The line
System.out.println(".");
is outside the nested for
. If you want it inside, you should use brackets {}
:
for (int i = 0; i < 10; i++) {
for (int c = 0; c < 10; c++) {
if (i == c) {
System.out.print("*");
} else {
System.out.print("-");
}
System.out.println(".");
}
}
Remember that if you don't put brackets {}
, the body of the for
loop will only be one statement (the one which is next to the for
declaration).