Is it possible to configure the Java StringBuilder class to append a new line between each call to append?
Is it possible to configure the Java StringBuilder class to append a new line
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think
StringBuilderhas that functionality built-in. Since you can’t just extend it, you could try using the decorator pattern…Alternately Java can support this shorthand, which is useful in that it is not necessary for the decorator to reimplement all methods that need to be available from the decorated class, however it is more dangerous as the raw resource is completely unexposed so that trade-off must be weighed: