I noticed that when equals() is used to compare between two String objects it works fine. But when I compare two StringBuffer objects or two StringBuilder objects or mix of String and Builder and Buffer, equals() doesn't work even though I give same string value to the two objects being compared.
However when I say it doesn't work, I mean it compiles fine, but it just says unequal according to if loop.
Then I checked Java docs online under Buffer and Builder API and equals() is not listed under methods summary for them but it is listed for String.
So my understanding is that equals doesn't work at all for Buffer and Builder but only for String? Correct me if I'm wrong please.
And second, if equals is not available for Buffer and Builder, then what is the alternate to compare the different object's contents for them?
P.S. I have typed Buffer and Builder for StringBuffer and StringBuilder as a typing convenience. Please don't confuse otherwise. Thanks.