Simple nested for loop example

后端 未结 7 632
后悔当初
后悔当初 2021-01-18 01:15

Currently I am studying for my Java test. Whist studying I\'ve come across a small problem.

In this for loop:

for ( int i=1; i <= 3 ; i++ ) {
            


        
7条回答
  •  独厮守ぢ
    2021-01-18 02:02

    You have a loop inside another loop.

    So for every iteration of the outer loop, you will run the inner loop to completion, starting at 1 ending at 3.

    So you end up printing j=1,2,3, for each value of i. In this case i is 1,2, and 3.

提交回复
热议问题