How to make for loops in Java increase by increments other than 1

前端 未结 13 1733
情书的邮戳
情书的邮戳 2020-12-24 04:33

If you have a for loop like this:

for(j = 0; j<=90; j++){}

It works fine. But when you have a for loop like this:

for(j          


        
13条回答
  •  自闭症患者
    2020-12-24 05:05

    Simply try this

    for(int i=0; i<5; i=i+2){//value increased by 2
    //body
    }
    

    OR

    for(int i=0; i<5; i+=2){//value increased by 2
    //body
    }
    

提交回复
热议问题