Reputation: 21
I have a class tiles(or squares) for a chess board:
`
class Tile {
int number;
float x;
float y;
String name;
Tile(int number, float x, float y, String name) {
this.number = number;
this.x = x;
this.y = y;
this.name = name;
}
int getNumber() {
return number;
}
float getX() {
return x;
}
float getY() {
return y;
}
}
`
When I try and run my code (in which for testing purposes I call a method that takes an instance of tile and calls it's number value and checks to see if a piece can move to that tile), I immediately get a syntax error on line 28 which is the line right after the last bracket in this class:
Syntax Error - Incomplete statement or extra code near ‘extraneous input '' expecting {'color', 'abstract', 'boolean', 'byte', 'char', 'class', 'double', 'enum', 'final', 'float', 'import', 'int', 'interface', 'long', 'native', 'private', 'protected', 'public', 'short', 'static', 'strictfp', 'synchronized', 'transient', 'var', 'void', 'volatile', '{', '}', ';', '<', '@', IDENTIFIER}’?
To my knowledge, this would typically be just a bracket misplacement or something but I cannot for the life of me figure out what is wrong. It could just be that I've been going at it for the entire day, but I tried running my code in a separate online Java compiler and it works completely fine. What is wrong?
Upvotes: 1
Views: 7870
Reputation: 88
You are probably going to laugh at this and wonder why this is even a feature in the Processing IDE but the reason why this error shows is not because there is anything wrong in the written code on that file. However, it is due to incomplete code on another file in the same program.
For example consider these images links Player Class. There is nothing wrong with this piece of code but it still shows the following error on line 22. This is funnily enough not due to anything wrong on line 22 but in the previous file Enemy Class.
I am not aware if this is a common feature across IDEs but it is a problem on Processing 4.1.1 which is Java based.
Hope this helps.
Upvotes: 3