I am in a beginner java programming class and currently reviewing loops. If there is one thing I just do not understand, it\'s pyramids. I have researched the book exercis
There are 7 rows in the pyramid, so the first for loop is looping over the rows, the second for loop is printing a bunch of spaces so that the triangle doesnt appear as:
1
2 1 2
3 2 1 2 3
The third for loop (with k), has a conditional operator which works like this:
boolean-expression ? result-if-true : result-if-false
So it either adds the number k to the string, or adds a space and then the number k to the string.
Fourth loop does a similar thing.