I am trying to make a program that print the following numbers :
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
The code is
public class JavaApplication8 {
public static void main(String[] args) {
int i = 1;
int j = 1;
while (i <= 2 && j <= 4) {
while (i <= 2 && j <= 4) {
System.out.printf("%d%d\n", i, j);
j++;
}
j = j - 4;
i++;
System.out.printf("%d%d\n", i, j);
j++;
}
}
}
The program prints this
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
I don't know why this is happening behind the condition inside while says that it i must be smaller or equal 2