I have a java method that passes in a string and is comparing the value in the string to a direction (i.e "East", "West", "North", "South"). When it finds a match it returns an Directions object (i.e Directions.East, Directions.West, Directions.North, Directions.South). I am making the call to the method as follows: convertDirection(eElement.
Here is the method:
private static Directions.Direction convertDirection(String dir)
System.out.printf("Direction in method: %s Length=%d\n", dir, dir.length());
If the XML attribute contains "West", when I debug the method, dir shows "West" and the string length of dir is 4 so I don't have any extra unseen characters. However, the if(dir=="West") statement returns false so it doesn't return my West direction and falls through to the end of the method and returns North. If I hard code the call as follows:
The method works correctly. I've tried creating a string variable and assigning the results of eElement.getAttribute("sta
n") to the variable and passing that into the method but it still doesn't work.
Any help is greatly appreciated as I have to have this working by tomorrow morning and I am at a complete loss.