Chaining methods using power of "return this"
In one of my older post [here], I discussed about the power of Fluent Interfaces. We can use those in building method chaining, thus improving the readability of code just english-like sentences.
We can also implement this using "return this" in class methods.
Take a look at below source code:
Bug.java
CreateBugs.java
Output:
The above programs are self explanatory :)
No comments:
Post a Comment