Skip to content
Advertisement

Syntax error on token “;”, “{” expected after this token

Just a simple class calls a class that prints an array. I get a syntax error in Eclipse. I also get an error that I don’t have a method called Kremalation.

JavaScript

Advertisement

Answer

You have code (which is not declaring a variable and/or initializing it) ouside a method, which is:

JavaScript

In Java, code MUST reside inside a method. You can’t call a class, you have to call a method that is declared inside a class.

WRONG:

JavaScript

CORRECT:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement