That isn't the right way to compare two Strings to see if their contents are correct. That just compares to see if they are actually the same String object, which is a different thing entirely. Two different String objects can certainly contain the same data, and that's what is happening here. You should use String's equals() method to see if two Strings contain the same sequence of characters.