String StringBuffer StringBuilder
2015-07-09 23:52
489 查看
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.
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.
相关文章推荐
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android之获取手机上的图片和视频缩略图thumbnails
- android string.xml文件中的整型和string型代替
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- 插入排序
- 冒泡排序
- 堆排序