increment 2 in for loop java code example
Example: java for increment by 2
int n = 2; //Or any other number
for (int i=0; i < 10; i+=n){
System.out.println(i) //This will print 0,2,4,6,8
}
int n = 2; //Or any other number
for (int i=0; i < 10; i+=n){
System.out.println(i) //This will print 0,2,4,6,8
}