String StringBuffer StringBuilder

The String class represents character string. All string literals in java program are implemented as instances of this class. 

Strings are constant, their values cannot be changed after they are created. Because String objects are immutable, they can be shared.

String concatenation is implemented through the StringBuilder and StringBuffer class and its append method.

Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.


StringBuffer class is a thread-save, mutable sequence of characters. A string buffer is like a string, but can be modified. String buffers are safe to use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is  consistent with the order of the method calls made by each of the individual threads involved.


StringBuilder is also a mutable sequence of characters. This class provides an API compatible with StringBuffer, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations, as it supports all of the same operations but it is faster, as it performs no synchronization.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jefferyqjy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值