krishnadhar Mellacheruvu wrote:y does not the statement int i;; give an error.
Bear Bibeault wrote:Why (note that why is spelled "why" not "y") do you feel that it should?
krishnadhar Mellacheruvu wrote:
because empty line terminators can be used as code page fillers. It's just a thought. is it a valid one ?
Tim Holloway wrote:Actually, the semicolon is neither a line terminator nor a statement separator. It's a statement terminator.
Tim Holloway wrote:There are probably some cases in Java where they aren't allowed.
Paweł Baczyński wrote:Please correct me if I'm wrong. I think that an empty statement is legal at any place where a statement is legal.
JLS wrote:14.14.1. The basic for Statement
The basic for statement executes some initialization code, then executes an Expression, a Statement, and some update code repeatedly until the value of the Expression is false.
BasicForStatement:
for ( [ForInit] ; [Expression] ; [ForUpdate] ) Statement
(...)
ForInit:
StatementExpressionList
LocalVariableDeclaration
ForUpdate:
StatementExpressionList
StatementExpressionList:
StatementExpression {, StatementExpression}
Paweł Baczyński wrote:You have statement expressions there. So an empty statement is not allowed there because no statement is allowed there.
Winston Gutkowski wrote:
Paweł Baczyński wrote:You have statement expressions there. So an empty statement is not allowed there because no statement is allowed there.
Sounds like splitting hairs to me, because precisely the same rule applies whether inside a class, method, block, or loop:
int i = 0, j = 0;
is legal:
int i = 0, ;
is not.
Stevens Miller wrote:I'd be willing to sub-split that particular hair and say that [...] is not legal...because only undeclared identifiers (in the given scope) can follow the comma separator in that context.
JLS wrote:LambdaExpression:
LambdaParameters -> LambdaBody
JLS wrote:LambdaBody:
Expression
Block