How do I update the next line in StringBuilder?

Asked 2 years ago, Updated 2 years ago, 40 views

Use the StringBuilder object as shown below.

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

I want to put a text message that updates the line to the next line, how do I do it?

I said result.append("/n"); but it doesn't work? I think this is a new line text, no?

java string

2022-09-21 16:48

1 Answers

result.append("\n"); You can say that. And more than this, result.append(System.getProperty("line.separator")); I recommend doing it this way. The line.separator is a system-independent wrap keyword (?) in Java. In Java 7, you can also write System.lineSeparator() like this.


2022-09-21 16:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.