Comparing getString to String problem
I have some JSP code that's comparing a String value from a database and a hardcode value set in JSP...
String myName = "Terry";
tmp = r.getString("fname");
if (String.valueOf(tmp) == String.valueOf(myName))
System.out.println("You da man!");
System.out.println("-" + tmp + "- != -" + tmp2 + "-");
This code prints:
-Terry- != -Terry-
It seems like they are different variable type (getString and String) and aren't being compared properly. I was wondering if there was some way to convert getString to be compatiable with String.
Thanks for help,
Comments on this post
I'm gonna answer my own question...
You can't compare Strings with "==" you have to use ".equals()"
String tmp = "Terry"