StringBuilder .equals Java

Yes, StringBuilder does not override Object's .equals() function, which means the two object references are not the same and the result is false.

For StringBuilder, you could use s1.toString().equals(s2.toString())

For your edit, you’re calling the == operator on two different String objects. The == operator will return false because the objects are different. To compare Strings, you need to use String.equals() or String.equalsIgnoreCase()

It’s the same problem you were having earlier

Leave a Comment