==
compares object reference contents
i.e. str1
and str2
and not object contents
while equals()
does compare object contents
i.e (objects pointed by str1 and str2)
Also check this :
String str1 = "Hi there";
String str3 = "Hi there";
str1 == str3 => true
This is because JVM handles string literals in different way. Check here