If you are going to compare any assigned value of the string i.e. primitive string, both "==" and .equals will work, but for the new string object you should use only .equals, and here "==" will not work.
Example:
String a = "name";
String b = "name";
if(a == b)
and (a.equals(b))
will return true.
But
String a = new String("a");
In this case if(a == b)
will return false
So it's better to use the .equals
operator...