Reputation: 1090
I am probably just being stupid, but I am attempting to create a variable and am getting this error:
Syntax error on token "continue", invalid VariableDeclaratorId
The line of code is
static boolean continue = false;
For some reason if I change the variable name it seems to work, however I would really prefer to use the variable name "continue" because it is easier to remember than "cont" or any other variation, which is important to me.
So, is there any way that I can declare this variable?
Upvotes: 1
Views: 840
Reputation: 8946
The javadoc says Also keep in mind that the name you choose must not be a keyword or reserved word.
As continue
is a keyword in the Java language, so you can never use it as a identifier for your variable.
Upvotes: 0
Reputation: 6527
continue
is a predefined keyword in Java
.
You cannot use varaiableName as reserved keywords.
This shows the list of keywords in Java
Upvotes: 0
Reputation: 15860
Continue is a keyword in the Java language, so you cannot use it as a identifier for your variable. Declare the variable you have as
static boolean continue = false;
You cannot use the variable names as one of the keywords of the language. Otherwise you'll get this error while compiling the code.
If you still want the continue
, use it as Upper Case. Or change it to something else. But not the continue as it is.
Upvotes: 8