I know that ==
has some issues when comparing two Strings
. It seems that String.equals()
is a better approach. Well, I’m doing JUnit testing and my inclination is to use assertEquals(str1, str2)
. Is this a reliable way to assert two Strings contain the same content? I would use assertTrue(str1.equals(str2))
, but then you don’t get the benefit of seeing what the expected and actual values are on failure.
On a related note, does anyone have a link to a page or thread that plainly explains the problems with str1 == str2
?