public final class StringBuffer
extends AbstractStringBuilder
implements java.io.Serializable, CharSequence
 /**
* A cache of the last value returned by toString. Cleared
* whenever the StringBuffer is modified.
*/
private transient char[] toStringCache;//被transient修饰,表示这个字段不被序列化

StringBuffer是被final修饰的,表示不能被其它类继承,;继承了AbstractStringBuilder抽象类,实现了Serializable、CharSequence接口

StringBuffer中的方法被public修饰的都使用了synchronized,保证线程安全。所以StringBuffer是线程安全的类。
 /**
* Constructs a string buffer with no characters in it and an
* initial capacity of 16 characters.
*/
public StringBuffer() {
super(16);
} /**
* Constructs a string buffer with no characters in it and
* the specified initial capacity.
*
* @param capacity the initial capacity.
* @exception NegativeArraySizeException if the {@code capacity}
* argument is less than {@code 0}.
*/
public StringBuffer(int capacity) {
super(capacity);
} /**
* Constructs a string buffer initialized to the contents of the
* specified string. The initial capacity of the string buffer is
* {@code 16} plus the length of the string argument.
*
* @param str the initial contents of the buffer.
*/
public StringBuffer(String str) {
super(str.length() + 16);
append(str);
}

StringBuffer的容量默认是16,当容量不够的时候,容量会继续增加16,依次类推。

最新文章

  1. entityframework学习笔记--006-表拆分与实体拆分
  2. [转载]El Capitan 中 SIP 介绍
  3. 剑指Offer面试题:12.在O(1)时间删除链表结点
  4. T-Sql(七)用户权限操作(grant)
  5. tp5页面输出时,搜索后跳转下一页的处理
  6. iOS/Android网络消息推送的实现两种方法
  7. git 回滚
  8. 【uTenux实验】写在开始实验之前
  9. php 用post请求调用接口api
  10. 从jdbc到mybatis
  11. std::forward_list
  12. J Query库
  13. MySQL连接数实时查看
  14. ASP.NET Core轻松入门之Configure中IHostingEnvironment和IApplicationLifetime的使用
  15. glusterfs 4.0.1 rpc 分析笔记1
  16. 3D GIS 应用开发 —— 基于 Mapbox GL 的实践总结
  17. 编写函数,接受一个string,返回一个bool值,指出string是否有5个或者更多字符,使用此函数打印出长度大于等于5的元素
  18. Java类集 List, Set, Map, Stack, Properties基本使用
  19. Oracle如何解决日期格式“01-3月 -18”的显示问题(3种处理方式)
  20. Spark 编程模型(下)

热门文章

  1. wish - 简单的窗口式(windowing) shell
  2. 使用当前平台的 gcc 编译内核头文件
  3. c结构体指针使用
  4. 【学术篇】SDOI2008 仪仗队
  5. NOIP提高真题整理(2011-2018)-标签
  6. 如何使用flow进行静态类型检查
  7. vue+ElementUI——表格分页(前端实现方法)
  8. canvas插入图片设置背景,渐变
  9. linux shell下除了某个文件外的其他文件全部删除的命令
  10. [JZOJ6299] 2019.08.12【NOIP提高组A】工厂