Retrived data is showing null string
I am setting data as follows:
currentRoom.setExits(null,theatre,pub.office)
But getExit returns garbage values for last three
routines re below:
Code Java:
public Room getExit(String direction)
{
if (direction=="north") {
return northExit;
}
if (direction=="east"){
return eastExit;
}
if (direction=="south"){
return southExit;
}
if (direction=="west"){
return westExit;
}
return null;
}
public void setExits(Room north, Room east, Room south, Room west)
{
if(north != null)
northExit = north;
if(east != null)
eastExit = east;
if(south != null)
southExit = south;
if(west != null)
westExit = west;
}
Re: Retrived data is showing null string
Quote:
But getExit returns garbage values
Please copy and paste here the output that is shown.
Use the equals() method when comparing the contents of String objects.
The == operator is for primitives (or for testing if two object references point to the same object)
Re: Retrived data is showing null string
Quote:
Originally Posted by
Norm
The == operator is for primitives (or for testing if two object references point to the same object)
Please see == operator or equals() method