Why do we need capacity in StringBuilder
问题 As we know, there is a attribute in StringBuilder called capacity, it is always larger than the length of StringBuilder object. However, what is capacity used for? It will be expanded if the length is larger than the capacity. If it does something, can someone give an example? 回答1: You can use the initial capacity to save the need to re-size the StringBuilder while appending to it, which costs time. If you know if advance how many characters would be appended to the StringBuilder and you