for(System.out.print("a"),int a = 1;a <3,System.out.print("b");System.out.print("c"))
{
i++;
System.out.println("我是换行");
}
}
}
复制代码
为什么第一个for正常运行,第二个for却是编译出错了呢?作者: 黄金龙 时间: 2013-1-28 17:06
for(System.out.print("a"),int a = 1;a <3,System.out.print("b");System.out.print("c"))
for 中间那个判断要返回真假的才可以的......不然你咋判断??????System.out.print("b")这个没真假的意思吧作者: 李跃达 时间: 2013-1-28 17:10
for(System.out.print("a"),int a = 1;a <3,System.out.print("b");System.out.print("c"))//亲第一个表达式和第二个表达式这里应该是分号不是逗号
13. {
14. i++;
15. System.out.println("我是换行");
16. }
作者: 朱玉玺 时间: 2013-1-28 17:47
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 ( ForInitopt ; Expressionopt ; ForUpdateopt ) Statement
ForStatementNoShortIf:
for ( ForInitopt ; Expressionopt ; ForUpdateopt )
StatementNoShortIf
ForInit:
StatementExpressionList
LocalVariableDeclaration
ForUpdate:
StatementExpressionList
StatementExpressionList:
StatementExpression
StatementExpressionList , StatementExpression
The Expression must have type boolean or Boolean, or a compile-time error
occurs.作者: 李培根 时间: 2013-2-18 11:39
请勿复制他人帖子,技术分不是入学的门槛而是为了帮助大家学习而存在的。