博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Class StringBuffer
阅读量:4197 次
发布时间:2019-05-26

本文共 2284 字,大约阅读时间需要 7 分钟。

public final class StringBuffer extends  implements , 
A thread-safe, 
mutable可变 sequence序列 of characters. A string buffer is like a  , but can be 
modified修改. At any point in time it contains some 
particular特定 sequence of characters, but the length and 
content内容 of the sequence can be changed through 
certain某些 method 
calls调用.

String buffers are safe for use by multiple threads多线程. The methods are synchronized同步where necessary必要 so that all the operations操作 on any particular特定 instance实例 behaveas 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涉及.

The principal主要 operations操作 on a StringBuffer are the append and insert methods, which areoverloaded重载 so as to accept接受 data of any type. Each(方法能) effectively 有效converts转换 a given datum数据 to a string and then appends or inserts the characters of that string to the string buffer字符缓冲区. The append method always adds these(字符) characters at the end of the buffer; the insert method adds the characters at a specified指定 point.

For example, if z refers to引用 a string buffer object whose current contents当前内容 are "start", then the method call调用 z.append("le") would cause the string buffer to contain "startle", whereas z.insert(4, "le") would alter the string buffer to contain "starlet".

In general通常, if sb refers to an instance实例 of a StringBuffer, then sb.append(x) has the same effect效果 as sb.insert(sb.length(), x).

Whenever an operation操作 occurs发生 involving有关 a source sequence源序列 (such as appending or inserting from a source sequence) this class synchronizes only on the string bufferperforming the operation执行此操作, not on the source(同步).

Every string buffer has a capacity容量. As long as the length of the character sequence contained in the string buffer does not exceed 超过the capacity, it is not necessary to allocate分配 a newinternal内部 buffer array. If the internal buffer overflows超过溢出, it is automatically自动made larger. As of release开始 JDK 5, this class has been supplemented补充 with an equivalent等价 class designed for专为 use by a single thread, . The StringBuilder class should generally通常 be used in preference to优先this one, as it supports all of the sameoperations操作 but it is faster, as it performs执行 no synchronization.

转载地址:http://nhzli.baihongyu.com/

你可能感兴趣的文章
Docker 容器化技术介绍(四) 之 Docker的安装与启动
查看>>
Docker 容器化技术介绍(五) 之 Docker 镜像操作
查看>>
Docker 容器化技术介绍(六) 之 Docker 容器操作
查看>>
Docker 容器化技术介绍(七) 之 Docker 应用部署
查看>>
Docker 容器化技术介绍(八) 之 Docker 备份与迁移
查看>>
ffmpeg 转码线程数的控制
查看>>
Docker 容器化技术介绍(九) 之 Docker 安装指定版本安装包
查看>>
python 能不能像执行 .exe 文件一样执行 .py 文件呢?
查看>>
Android studio 视频播放(利用Android原生的videoview)
查看>>
“mediacodec” 报错 “No Java virtual machine has been registered”
查看>>
Android Studio 常用系统设置
查看>>
GO语言开发之JSON处理 编码JSON 与 解码JSON
查看>>
爱奇艺 视频编码信息参考
查看>>
x265 视频编码默认参数
查看>>
ffmpeg 视频倍速播放 和 慢速播放
查看>>
x264 高级编码参数
查看>>
ffmpeg 分析两个视频的 psnr 和 ssim
查看>>
Docker 容器化技术介绍(十) 之 Docker 挂载本地目录
查看>>
ffmpeg 实现 视频与gif互转
查看>>
Android 按钮响应点击事件的三种实现方式
查看>>