This Code worked on a separate class but does not work on another class
this one is working on: public class Table {
public int player() {
Scanner in = new Scanner(System.in);
p = in.nextInt();
return p;
}
but does not work on another class but under main:
public static void main (String[] args){
Please help as this puzzles me as I am very new in JAVA ... thank you in advance
Re: This Code worked on a separate class but does not work on another class
Please post the full text of the error messages and the full code that is causing them.
Re: This Code worked on a separate class but does not work on another class
Are you trying to copy the code from the method player() into method main()
If so, here is the answer: methods having void type cannot return any values, the return statement needs to be replaced with something meaningful.
Re: This Code worked on a separate class but does not work on another class
@ ranjithfs1:
I am trying to copy the whole method from another class to main. Even if I remove the return there is still error.
"Multiple markers at this line
- Syntax error on token(s), misplaced construct(s)
- Syntax error on token "int", @ expected.
@Norm: That is the whole code already.
Re: This Code worked on a separate class but does not work on another class
Please post the full text of the error messages and the code that is in the source file. Copy it exactly as it is in the source file and paste it here.