I am trying to execute the following code snippet:
connectionMap = new Hashtable<Directions, Room>();
connectionMap.put(Directions.SOUTH, corr);
hall.setMap(connectionMap);
connectionMap.clear();
connectionMap.put(Directions.SOUTH, dining);
corr.setMap(connectionMap);
I notice that all rooms end up getting the last value of connection map despite clearing it before setting up each Room. Can someone please explain what might be causing this? Creating a new map at every point apprears to be a bad coding style. Are there better solutions?
Thanks,