I am new to Java and I am trying to understand Nested while loops. I am trying to write a program that will print the following output:
999999999 on the top line,
88888888 on the next,
7777777 etc,
666666 etc,
55555
4444
333
22
1
I was easily able to do this using a for loop, but now I want to do the same with a While Loop. The issue is that my code, in its current state, only prints the first line of nines, and then it looks like the inner While loop doesn't run anymore afterwards.
I am super perplexed, I don't think any of my criteria are Tautologies, but I don't understand tautologies that well. Please explain what is wrong with my loop logic. Loops are still a lot of mystical voodoo to me.
int outer = 9;
int inner = 1;
while (outer >= 1)
{
while(inner <= outer)
{
System.out.print(outer);
inner++;
}
System.out.println();
outer--;
}