This is a question out of curiousity.
Today I took a look at the implementations of StringBuilder and StringBuffer. Here's the append() method:
public StringBuilder append(String str) {
super.append(str);
return this;
}
AbstractStringBuilder.append(str) also returns this. Are there any benefits of discarding the return value (in StringBuilder.append(..)) and returning this again, instead of casting the return value of the super call to the current concrete implementation.
My first thought is that casting can be expensive, so if it can be avoided that would be best.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With