Hello everyone.
I am learning Java at the moment and I have problems to understand connected for-loops.
Let me explain what I mean by some quite easy example:
The outcome is simple as that:
Ok so my thoughts are these:
- first check if
1 < 3. That's true, enter the instructions in the inner loop
- check if j <= i, meaning
1 <= 1. True, print out one Star *.
- finished instructions in the inner loop, so next step is j++, meaning j = 2.
- check if j <= i, meaning
2 <= 1. That's wrong, the inner loop is done.
- print out new line
- outer loop: i++ (must be increased). Then i = 2 = j.
- ok, now enter outer loop again (condition true)
- inner loop: j <= i, meaning 2 <=2 = true.
- =>=>=> print ONE Star *.
I don't understand, why it prints 2 Stars at that point. Any help would be highly appreciated