Issue
I'm trying to program an appointment program and I'm a beginner at java. I'm using VScode.
the code:
public class Main {
public static void main(String[] args) throws FileNotFoundException, IOException {
a.menuPrint(); //Prints menu to begin
}
}
I'm getting this error:
a cannot be resolved
at Main.main(Main.java:7)
The a
variable is supposed to print the menu. I don't know why it can't be resolved. Are there any reasons why?
Solution
There is not enough information here to decide. Typically "cannot be resolved" means that you are using an object that is not declared in the block where it is being used and it is not global.
In your example, variable a
is being used in the main
method. If a
is not a global variable, that explains the problem: inside the method body, a
is not defined (cannot be resolved to whatever type that variable is).
To fix:
public static void main(String[] args){
WhateverClass a = new WhateverClass();
a.menuPrint();
}
Answered By - hfontanez Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.