This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The StringBuffer class does not override equals() it uses the one from the Object class. Refer API. The Object equals() method checks for the equality of the references. In your code sb1 and sb2 have different references, therefore the code should compile fine, but return a false, even though the Strings are identical. You can try the following piece of code to check if the references contain identical Strings, . The output will be true.