I'm studying repetition structure in Java here. And I came across the urge to do the following:
public class Teste {
public static void main(String[] args) throws IOException {
for (int i = 1; i <= 2; i++) {
for (int j = 1; j <= 2; j++) {
System.out.println("Linha: " + j);
}
System.out.println(" Registro: " + i);
}
}
}
The output of this section is:
Linha: 1
Linha: 2
Registro: 1
Linha: 1
Linha: 2
Registro: 2
And the desired output would be:
Linha: 1
Linha: 2
Registro: 1
Linha: 3
Linha: 4
Registro: 2
That is, in the second spin of the first loop, j was not zeroed, thus generating Line 3 and Line 4 for the second register.
How do I do this?