I’m learning Java, and using this for statement for looping:
for (int i = 0; i <3; i++){
...
}
I’m wanting to toggle a fill color every time the loop runs. I’m not wanting to give too many examples, because I’m not looking for the answer to my specific issue, but I want to know if there is a way of doing this?
Basically evey odd time the loop runs, it does x and every even time it runs, it does y?
EDIT: after typing this, I’m thinking maybe I can do an if statement with the int i? something like if i % 2 == 0 {}
?
PS: I am hereby expressing my excitement.
Add a mod operator. If i % 2 == 0 then do something for even, else do something for odd.