string1.equals(string2)
is right way to do it.
String s = "something", t = "maybe something else";
if (s == t) // Legal, but usually results WRONG.
if (s.equals(t)) // RIGHT way to check the two strings
/* == will fail in following case:*/
String s1 = new String("abc");
String s2 = new String("abc");
if(s1==s2) //it will return false