-
problem compiling class
I've got a class (ArrayMenu) which uses class (Keyboard) to read which key is pressed to choose from a menu. Keyboard compiles but ArrayMenu has this error (and I don't understand what I've done wrong!) Any one help - please!
---------- javac ----------
ArrayMenu.java:33: cannot resolve symbol
symbol : variable Keyboard
location: class ArrayMenu
choice = Keyboard.readChar();
^
1 error
Output completed (1 sec consumed) - Normal Termination
If anyone wants to see the code for the classes I will post them
-
remove the package statement at the top of the keyboard.java file. then recompile keyboard.java, and place it in the same directory as ArrayMenu.java.
Good ol Java Software Solutions by Lewis and Loftus?
-
if I remove the package from Keyboard I get 6 errors and it will not compile. ArrayMenu will still not compile. They are both in the same directory
-
You must not have the one i was thinking of. sorry dude.
-
Is readChar() a static method?
I ask because you've used Keyboard.readChar(). This means (I think) that it needs to be static. If its not then I think that the compiler tries to resolve Keyboard as a variable and not a class.
If its not static you need to declare a variable of typ Keyboard first.
If its not this problem then have you imported the class - it shouldn't be a problem cos they're in the same directory - but you never know. Are they in the same package?
I've asked a few questions as I'm not sure whats happening. If you need more help, give us a shout.
HD