I believe the poster wrote the code in an IDE, such as eclipse. This is a compilation error, because the code is not standardized, and because the IDE will check the syntax of the code when you write it. So you will get the unexpected token error. Only methods and variables can be defined under class. But you cannot write logic code directly. You should define these codes in a method, such as
class FB {
public void list() {
int i = 0;
while(i>=0){
i++;
}
}
}
In addition, this code is actually problematic because it is an infinite loop.
I believe the poster wrote the code in an IDE, such as eclipse.
This is a compilation error, because the code is not standardized, and because the IDE will check the syntax of the code when you write it. So you will get the unexpected token error.
Only methods and variables can be defined under class. But you cannot write logic code directly. You should define these codes in a method, such as
In addition, this code is actually problematic because it is an infinite loop.
I don’t know what you want to do. Anyway, your code is indeed wrong. You actually wrote the statement in class,
class list {
}
There should be a function in the class, and then write a while statement inside it
Are you sure you have read the Java syntax once?
class list{
public void test(){
}
}
What language is this?
You have a grammatical error and the compilation will not pass.