I'm unable to compare two strings using the following code:
I have a string named "gender" which will have "Male" or "Female" as its value.
if(gender == "Male")
salutation ="Mr.";
if(gender == "Female")
salutation ="Ms.";
This didn't work, so I tried the following:
String g1="Male";
String g2="Female";
if(gender.equals(g1))
salutation ="Mr.";
if(gender.equals(g2))
salutation ="Ms.";
Again, it didn't work. Can someone please tell me how to compare string values using the if statement.