You're right, I'd don't see the big advantage to having *some* methods allow chaining, especially why other PrintWriter methods don't. For example, you can write:
but not
Because all the print methods have void return type. (One could argue that it's time to use printf, but not everyone likes using formating when they don't have to...)
Did you notice the cool thing happening in PrintWriter? It implements Appendable:
And when it implements these methods, it uses
Java 1.5's
covariant return types to change the return type of these methods to PrintWriter. (I can't think of another place in the API that they use CRT ...) The API for Appendable also states:
The Appendable interface must be implemented by any class whose instances are intended to receive formatted output from a Formatter.
A-ha...