Two objects can hold the same data and still be different objects in memory. == checks whether two references point to the same object, while equals() checks whether the contents are the same. Use equals() for strings and other objects whenever you mean "same value", and == for primitives. Mixing them up gives code that works in one test and fails in another, which is why it appears in so many output questions.