Simple nested for loop example

后端 未结 7 514
后悔当初
后悔当初 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:04

    The outer for "grabs" the inner for and iterates over IT. i.e., you have a for loop within a for loop. For each of i in the range 1..3, you must loop j from 1..3 also. As i becomes 2, j resets to 1 and the inner loop runs all over again.

    0 讨论(0)
提交回复
热议问题