Take a look at the
StringBuffer.append javadoc. There you will see that the append method returns the StringBuffer itself.
The second method is called on the object the first method returns, which is the StringBuffer itself.
If your own first method returns something else or nothing at all, you will get a compilation error.
This type of interface is sometimes called a
Fluent interface