How to empty or remove the contents of StringBuilder

Asked 1 years ago, Updated 1 years ago, 101 views

I'm using StringBuilder in the repeat. And I'd like to repeat all the x's and empty the contents and write a new String Builder. On dotnet, StringBuilder.Clear Java supports delete but it seems too complicated to me.

Is there an easier way to empty the String Builder?

java stringbuilder

2022-09-21 16:50

1 Answers

There are two ways.

One is StringBulderObj.setLength(0); and the other is to allocate a new buffer instead of emptying it.


2022-09-21 16:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.