How to append a newline to StringBuilder

前端 未结 8 662
天涯浪人
天涯浪人 2020-12-04 06:37

I have a StringBuilder object,

StringBuilder result = new StringBuilder();
result.append(someChar);

Now I want to append a newline characte

8条回答
  •  一整个雨季
    2020-12-04 07:06

    Escape should be done with \, not /.

    So r.append('\n'); or r.append("\n"); will work (StringBuilder has overloaded methods for char and String type).

提交回复
热议问题