Difference between StringBuilder and StringBuffer

后端 未结 30 2799
独厮守ぢ
独厮守ぢ 2020-11-21 15:06

What is the main difference between StringBuffer and StringBuilder? Is there any performance issues when deciding on any one of these?

30条回答
  •  孤城傲影
    2020-11-21 15:25

    StringBuilder (introduced in Java 5) is identical to StringBuffer, except its methods are not synchronized. This means it has better performance than the latter, but the drawback is that it is not thread-safe.

    Read tutorial for more details.

提交回复
热议问题