Nested for loops
how does it produce a rectangular output
Both loops increasing OR both decreasing Have both loop counters conditions dependent on a known number, not a changing variable (i.e. i < 5, j <= 3) These nested loops produce "rectangular" output If the inner and outer loops run the same number of times, get "square" output
what if you have 2 triangular inner loops
Having two independent, triangular inner loops inside the same outer loop can produce a rectangle, depending on the output of the individual inner loops
how do you get a triangular shaped output
Instead of having the inner loop go up until an exact number ((e.g. condition being j < 5)) we could have it go up to the value of the outer loop ((e.g. condition being j < i))
what are nested for loops
Nested loops are loops within another loop
If we use an increasing outer loop with a decreasing inner loop OR a decreasing outer loop with an increasing inner loop & the inner loop's condition relies on the outer loop's counter, we can produce:
an upside down triangle
what's the purpose of the println line
prevents it from being one long line of print
the inside loop only runs if...
the outside loop is true
how long does the inside loop run before it goes back to the outer loop?
until its totally completed