I'm working with 2 different HashMap
s in a class, and when I call the keySet()
method with the first (the getExitString()
method), it works fine, but when I call it with the second (the getLockedDoors()
method), I get the "cannot find symbol - method keySet()
" error. How can I fix this? Thanks! The relevant code is below.
import java.util.HashMap;
import java.util.Set;
public class Room
{
private HashMap<String, Room> exits;
private HashMap<String, LockedDoor> lockedDoors;
public String getExitString() {
String exitReturn = "";
Set<String> exitSet = exits.keySet();
for (String eachExit : exitSet) {
exitReturn = exitReturn + eachExit + " ";
}
return exitReturn;
}
public String getLockedDoorString() {
String lockedDoors = "";
Set<String> doorSet = lockedDoors.keySet();
for (String door : doorSet) {
lockedDoors = lockedDoors + door + " ";
}
return lockedDoors;
}