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

前端 未结 13 1752
情书的邮戳
情书的邮戳 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 04:51

    It should be like this

    for(int j = 0; j<=90; j += 3) 
    

    but watch out for

    for(int j = 0; j<=90; j =+ 3) 
    

    or

    for(int j = 0; j<=90; j = j + 3)
    

提交回复
热议问题