I have some code, like so:
int batchPosition = new Integer(batchBegin);
for (batchPosition;batchPosition<=batchEnd;batchPosition++)
But I get this error in eclipse:
Syntax error, insert "AssignmentOperator Expression" to complete ForInit.
I’ve looked at various posts on SO about this error, and googled it but I can’t figure out why this isn’t allowed.
batchPositionon it’s own is not a valid initialisation statement – you can simply skip it:But if you don’t need to access
batchPositionafter your loop, it is good practice to reduce variables scopes as much as possible: