Hello,
I'm trying to make a simple program in Eclipse,
the code is allright exception made to
.Code java:public void run()
The error message is --Syntax error on token "void", @ expected
If anyone can help me I feel glad.
Niquinho
Printable View
Hello,
I'm trying to make a simple program in Eclipse,
the code is allright exception made to
.Code java:public void run()
The error message is --Syntax error on token "void", @ expected
If anyone can help me I feel glad.
Niquinho
Please post the code that generates the error, preferably as a stripped down version that demonstrates the problem (eg an SSCCE)
Ok,
The code is the following
Code java:public class tabuleiro extends GraphicsProgram { private static final int numrows = 8; private static final int numcolumns = 8; public static void main(String[] args) { public void run (){ int sqSize = getHeight() / numrows; for (int i = 0; i<numrows;i++); { for (int j = 0;j<numcolumns;j++); { int x = j*sqSize; int y = i*sqSize; Grect sq = new Grect (y,x,sqSize,sqSize); sq.setFilled (((i+j) % 2) !=0); add(sq); } } } } }
Thanks
A method: run() can not be defined inside of another method: main()
Add the ending } for one method's definition before starting to define a new method.
Hello again,
I add a } before run() and the program continues give me errors.
I would like to have the code that works.Code :public class tabuleiro extends GraphicsProgram { private static final int numrows = 8; private static final int numcolumns = 8; public static void main(String[] args) { }public void run (){ int sqSize = getHeight() / numrows; for (int i = 0; i<numrows;i++); { for (int j = 0;j<numcolumns;j++); { int x = j*sqSize; int y = i*sqSize; Grect sq = new Grect (y,x,sqSize,sqSize); sq.setFilled (((i+j) % 2) !=0); add(sq); } } } } }
Thanks.
When you get errors, you need to copy the full text of the error messages and post them here.Quote:
the program continues give me errors.
Ok, the error message is:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at tabuleiro.main(tabuleiro.java:6)
You need to get the error message from the compiler that says what the error is.
What you posted does not say what the error is. It just says: Unresolved compilation problem:
and gives a line number: 6
I don't know what the error is without a message that describes the error.
Error messages: GraphicsProgram cannot be resolved to a type; The method getHeight() is undefined for the type tabuleiro; j cannot be resolved to a variable; i cannot be resolved to a variable; ;Multiple markers at this line- Grect cannot be resolved to a type; Multiple markers at this line- i cannot be resolved to a variable.
I know is a lot of errors, but I'm trying to improve.
Do you need an import statement for the compiler to find GraphicsProgram?
The rest of the errors are very hard to solve because the error message does not show where the error is or what the source line was with the error.
Here is a sample compiler error message:
This is what you need to post if you want someone to help you solve the compiler errors.Code :TestSorts.java:138: cannot find symbol symbol : variable var location: class TestSorts var = 2; ^
Hello again,
Import statement for the compiler fo find GraphicsProgram?
Do some research about how to use the import statement.
http://docs.oracle.com/javase/tutori...e/usepkgs.html
Where is the GraphicsProgram class defined?
I will make some research, in order to understand where the GraphicsProgram is defined.
Thanks, for the link.