编译器构造错误:在Java中声明布尔值时不是语句
以下代码:
boolean continue = false;
返回以下错误:
error: not a statement
boolean continue = false;
^
为什么会这样?我对布尔人很熟悉
你可以在下面搜索框中键入要查询的问题!
以下代码:
boolean continue = false;
返回以下错误:
error: not a statement
boolean continue = false;
^
为什么会这样?我对布尔人很熟悉
# 1 楼答案
不能将
continue
用作变量名,因为它是保留字从the docs:
可以看出这是一个关键字,因为当您查看问题时,
continue
应用了语法突出显示,如boolean
和false
那就像写作一样
或
这两种方法显然都不起作用,因此请尝试其他类似
continuing
的方法:# 2 楼答案
请尝试以下方法:
或者用另一个名字。关键是,在Java中,
continue
是一个keyword,不能用作变量名-在语言规范中它是正确的here。对于未来的reference,这就是continue
的用途:# 3 楼答案
不能将continue用作变量的名称。这是java保留字之一