Only two Semicolons are allowed to be used in for
loop.
- Before first semicolon is the initialization part.
- After first semicolon and before second semicolon is condition part (must result in boolean).
- After second semicolon is variable manipulation part (increment/decrement part).
If you have do initialization of multiple variables or manipulation of multiple variables, you can achieve it by separating them with comma(,).
for(int i=0, j=5; i < 5; i++, j--)
NOTE: Multiple conditions separated by comma are NOT allowed.
for(int i=0, j=5; i < 5, j > 5; i++, j--) // This is NOT allowed.