Difference between StringBuilder and StringBuffer

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

    A String is an immutable object which means the value cannot be changed whereas StringBuffer is mutable.

    The StringBuffer is Synchronized hence thread-safe whereas StringBuilder is not and suitable for only single-threaded instances.

提交回复
热议问题