Java: StringBuffer & Concatenation

后端 未结 6 2032
梦如初夏
梦如初夏 2021-01-05 01:59

I\'m using StringBuffer in Java to concat strings together, like so:

StringBuffer str = new StringBuffer();

str.append(\"string value\");

6条回答
  •  抹茶落季
    2021-01-05 02:45

    StringBuffer is final. You cannot derive from it. The Best solution really is to add the padding for yourself. Write a method for it and use a PADDING-Constant so that you can easily change it, or better put it in a parameter.

提交回复
热议问题