Both StatementExpressionListand LocalVariableDeclarationare defined elsewhere on the page. I will copy them here:
StatementExpressionList:
StatementExpression
StatementExpressionList , StatementExpression
StatementExpression:
Assignment
PreIncrementExpression
PreDecrementExpression
PostIncrementExpression
PostDecrementExpression
MethodInvocation
ClassInstanceCreationExpression
and
LocalVariableDeclaration:
VariableModifiers Type VariableDeclarators
VariableDeclarators:
VariableDeclarator
VariableDeclarators , VariableDeclarator
VariableDeclarator:
VariableDeclaratorId
VariableDeclaratorId = VariableInitializer
VariableDeclaratorId:
Identifier
VariableDeclaratorId [ ]
VariableInitializer:
Expression
ArrayInitializer
There is no longer any sense in following grammar; I hope it will be easy enough to read as it is.
This means that you can have any number StatementExpressions, separated by commas or LocalVariableDeclarationin a section ForInit. And it LocalVariableDeclarationcan consist of any number of pairs " variable = value", separated by commas, which are preceded by their type.
So this is legal:
for (int i = 0, j = 0, k = 0;;) { }
because " int i = 0, j = 0, k = 0" is valid LocalVariableDeclaration. And this is legal:
int i = 0;
String str = "Hello";
for (str = "hi", i++, ++i, sayHello(), new MyClass();;) { }
because all these random things in the initializer qualify as StatementExpressions.
And since it is StatementExpressionListallowed in terms of updating the for loop, this is also true:
int i = 0;
String str = "Hello";
for (;;str = "hi", i++, ++i, sayHello(), new MyClass()) { }
?