Joel Christophel wrote:In other words, how is it that the sort method is void? I would expect to have to do list = Collections.sort(list);.
I think Jeanne's basically explained it to you, but you know what? I totally agree with you. I wish there was a version that also returned the List for you (
sortAndReturn?). Indeed, I've written one for myself.
I also tend to write my setters that way too (ie, return a copy of the object that contains the method). Guess I just don't like
void methods very much.
The style is used extensively with
fluid interfaces, which are
quite interesting; but you have to be careful - method chaining can produce some
horrible code.
Winston