That was pseudocode
The code will work incorrectly if it checks whether two references point to the same StringBuffer object or not.
The correct thing to do would be to compare the contents of the SBs by first converting them toString() and then comparing the resulting strings by equals().
PS : i tried comparing the SBs using only equals and it failed. Why ? And i cant even override equals since its final
so typing long code is the only way out.