I've been playing around with Android development recently, and that means working with Java.
Today I made the mistake of trying to compare two different string using == .
After quickly figuring out something was wrong, I learned this:
Comparing Strings: ==, .equals(), .compareTo(), ...
To compare Strings for equality, don't use ==. The == operator checks to see if two objects are exactly the same object. Two strings may be different objects, but have the same value (have exactly the same characters in them). Use the .equals() method to compare strings for equality. Similarly, use the .compareTo() method to test for unequal comparisons. For example,
String s = "something", t = "maybe something else"; if (s == t) // Legal, but usually WRONG. if (s.equals(t)) // RIGHT if (s > t) // ILLEGAL
if (s.compareTo(t) > 0) // CORRECT>
http://leepoint.net/notes-java/data/strings/12stringcomparison.html