Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

StringBuffers and appending

807606Mar 26 2007 — edited Mar 27 2007
I've inherited some Java code and the previous developer was appending to a StringBuffer by doing this...
StringBuffer sb = new StringBuffer();
sb.append("a").append("b").append("c").append("d");
It obviously works, but my question is... Is it good practice to code in this manner. Or should the code be more like this...
StringBuffer sb = new StringBuffer();
sb.append("a");
sb.append("b");
sb.append("c");
sb.append("d");
Is there any advantage to doing it one way or another? Or are the differences minimal?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2007
Added on Mar 26 2007
10 comments
218 views