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
The "increment" portion of a loop statement has to change the value of the index variable to have any effect. The longhand form of "++j" is "j = j + 1". So, as other answers have said, the correct form of your increment is "j = j + 3", which doesn't have as terse a shorthand as incrementing by one. "j + 3", as you know by now, doesn't actually change j; it's an expression whose evaluation has no effect.
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)
for(j = 0; j<=90; j = j+3)
{
}
j+3
will not assign the new value to j, add j=j+3
will assign the new value to j and the loop will move up by 3.
j++
is like saying j = j+1
, so in that case your assigning the new value to j just like the one above.
It's just a syntax error. You just have to replace j+3
by j=j+3
or j+=3
.
Change
for(j = 0; j<=90; j+3)
to
for(j = 0; j<=90; j=j+3)
If you have a for loop like this:
for(j = 0; j<=90; j++){}
In this loop you are using shorthand provided by java language which means a postfix operator(use-then-change) which is equivalent to j=j+1 , so the changed value is initialized and used for next operation.
for(j = 0; j<=90; j+3){}
In this loop you are just increment your value by 3 but not initializing it back to j variable, so the value of j remains changed.