File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes trying to use Hash Map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "trying to use Hash Map" Watch "trying to use Hash Map" New topic

trying to use Hash Map

Pete Malis

Joined: Dec 05, 2008
Posts: 3
I have a Game class,Room class and an Item class for this.

The room has a hashmap and trying to put items in the room using a hashmap as well almost copying the room class. I get an error in game though when trying to access the method. In game it errors on the second line

Room nextRoom = currentRoom.getExit(direction);
Item nextItem = currentItem.getItem(itemCommand);

saying cannot find symbol - variable item command

my method are the same in the Room class

then I have

"cannot find symbol- variable item command"

[edit]Add code tags. CR[/edit]
[ December 08, 2008: Message edited by: Campbell Ritchie ]
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
Use Code Tags!! as it makes your code much easier to read.

I assume this a compiler error "cannot find symbol-variable item command". It indicates that you are trying to reference a variable that has not been defined i.e. "item command". Where is the "itemCommand" String defined that is used in this line;

<a href="" target="_blank" rel="nofollow">Use Code Tags!!</a>
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46362
Please don't send anybody any zipped files; we want all discussion to be on the forum.
Have you posted the exact code you are using; there is nothing which would suggest such an error in what you have posted, and you cannot get an error message saying it can't find "item command" as two words.
Most likely explanation is that there is a tiny spelling error somewhere; try copying the parameter identifier into the get call arguments with ctrl-C ctrl-V.
I agree. Here's the link:
subject: trying to use Hash Map
It's not a secret anymore!