0
for loop
How to have increment of more than 1 in for loop?
4 Answers
+ 14
if i get you right you just simply need to increase increment count like this
for(var i = 0; i < 5; i+= 2){}
+ 3
Jason Mackjoo
Java:
Try this in the code playground and you will see that it is possible.
for(int i = 0; i <= 100; i += 5){
System.out.println(i);
}
Btw. a lot of stuff is possible with a for loop, but normally we don't do it. For example: for(; ;){//some code} (an infinity for loop without values)
+ 1
Instead
I++
Used
I +=2
Or
I= i+2
- 3
As far as i know, This cannot be done using for loop. Please check while loop.