Simple nested for loop example

后端 未结 7 512
后悔当初
后悔当初 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 01:50

    Each iteration of i, you're starting a completely new iteration of j.

    So, you start with i==1, then j==1,2,3 in a loop. Then i==2, then j==1,2,3 in a loop, etc.

    Step through it one step at a time, and it will make sense.

提交回复
热议问题