krishna anusha wrote: Then str1 and str2 are also different objects, but they are returning true. Why?
Because they are not different objects. The strings assigned to str1 and str2 are compile time constants, so the compiler uses the string pool, and hence, they refer to the same string object.
Henry