Difference between StringBuilder and StringBuffer

后端 未结 30 2406
独厮守ぢ
独厮守ぢ 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:29

    StringBuilder is not thread safe. String Buffer is. More info here.

    EDIT: As for performance , after hotspot kicks in , StringBuilder is the winner. However , for small iterations , the performance difference is negligible.

提交回复
热议问题