Method chaining example
What's happening is probably self explanatory: a new Student object is created and some of its fields are being set. The alternative is the less nice, yet more common, I guess
Method chaining alternative
Implementing method chaining is very straightforward: rather than returning void in your setters, you return an instance of the current object like this:
Method chaining alternative
Apart from slightly increasing readability, there are no general advantages to method chaining. In fact, this approach could become annoying when trying to debug that particular line where you chained your methods.
An interesting fact is that it was proposed that in Java 7 void methods implicitly return the current object, but this didn't make it into the language. Chaining will, however, be used quite often with Java 8 collections.
More on the topic & related:
Method chaining on Wikipedia
Fluent interface on Wikipedia
Fluent interfaces and Method Chaining in C#