Q:

Nested For Loop, Replace If statement

I have been practicing my nested for loops recently. I tried building a 5x5 block of coordinates going from (0,0) to (5,5). Each row will go up to y = 5 and then start a new row.
Here is the code I have built, it does what I want it to do, the only problem is that I had to use an if statement. Is there another for loop I could use to make it so that I don't have to use the if statement?
public class NestedLoops3 {
public static void main(String[] args) {

    for(int counter =0;counter<6;counter++) {
        for(int counter2 = 0;counter2<6;counter2++)
             {  
            System.out.print("("+counter+","+counter2+")");
            if(counter2==5) {
                System.out.println();
            }
    }
}
}
}

As it is right now it does what I intended but I just want to see if I can replace the if statement with another for loop.

A:

Yes. Move the println after the nested loop. Like,
for (int counter = 0; counter < 6; counter++) {
    for (int counter2 = 0; counter2 < 6; counter2++) {  
        System.out.print("(" + counter + "," + counter2 + ")");
    }
    System.out.println();
}

