如何清除或清空StringBuilder? [重复]

淺唱寂寞╮ 提交于 2020-08-05 04:48:36

问题:

This question already has an answer here: 这个问题已经在这里有了答案:

I'm using a StringBuilder in a loop and every x iterations I want to empty it and start with an empty StringBuilder , but I can't see any method similar to the .NET StringBuilder.Clear in the documentation, just the delete method which seems overly complicated. 我在循环中使用StringBuilder ,每隔x次迭代,我想将其清空并从一个空的StringBuilder开始,但是在文档中看不到任何类似于.NET StringBuilder.Clear的方法,只是删除方法似乎过于复杂。

So what is the best way to clean out a StringBuilder in Java? 那么用Java清理StringBuilder的最佳方法是什么?


解决方案:

参考一: https://stackoom.com/question/LmoC/如何清除或清空StringBuilder-重复
参考二: https://oldbug.net/q/LmoC/How-can-I-clear-or-empty-a-StringBuilder-duplicate
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!