StringBuilder 与 StringBuffer 区别
来源:互联网 发布:电脑照相机软件下载 编辑:程序博客网 时间:2024/05/01 18:56
/**
* A mutable sequence of characters. This class provides an API compatible
* with <code>StringBuffer</code>, but with no guarantee of synchronization.
* This class is designed for use as a drop-in replacement for
* <code>StringBuffer</code> 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
* <code>StringBuffer</code> as it will be faster under most implementations.
*
* <p>The principal operations on a <code>StringBuilder</code> are the
* <code>append</code> and <code>insert</code> methods, which are
* overloaded 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 builder. The
* <code>append</code> method always adds these characters at the end
* of the builder; the <code>insert</code> method adds the characters at
* a specified point.
* <p>
* For example, if <code>z</code> refers to a string builder object
* whose current contents are "<code>start</code>", then
* the method call <code>z.append("le")</code> would cause the string
* builder to contain "<code>startle</code>", whereas
* <code>z.insert(4, "le")</code> would alter the string builder to
* contain "<code>starlet</code>".
* <p>
* In general, if sb refers to an instance of a <code>StringBuilder</code>,
* then <code>sb.append(x)</code> has the same effect as
* <code>sb.insert(sb.length(), x)</code>.
*
* Every string builder has a capacity. As long as the length of the
* character sequence contained in the string builder does not exceed
* the capacity, it is not necessary to allocate a new internal
* buffer. If the internal buffer overflows, it is automatically made larger.
*
* <p>Instances of <code>StringBuilder</code> are not safe for
* use by multiple threads. If such synchronization is required then it is
* recommended that {@link java.lang.StringBuffer} be used.
* A mutable sequence of characters. This class provides an API compatible
* with <code>StringBuffer</code>, but with no guarantee of synchronization.
* This class is designed for use as a drop-in replacement for
* <code>StringBuffer</code> 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
* <code>StringBuffer</code> as it will be faster under most implementations.
*
* <p>The principal operations on a <code>StringBuilder</code> are the
* <code>append</code> and <code>insert</code> methods, which are
* overloaded 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 builder. The
* <code>append</code> method always adds these characters at the end
* of the builder; the <code>insert</code> method adds the characters at
* a specified point.
* <p>
* For example, if <code>z</code> refers to a string builder object
* whose current contents are "<code>start</code>", then
* the method call <code>z.append("le")</code> would cause the string
* builder to contain "<code>startle</code>", whereas
* <code>z.insert(4, "le")</code> would alter the string builder to
* contain "<code>starlet</code>".
* <p>
* In general, if sb refers to an instance of a <code>StringBuilder</code>,
* then <code>sb.append(x)</code> has the same effect as
* <code>sb.insert(sb.length(), x)</code>.
*
* Every string builder has a capacity. As long as the length of the
* character sequence contained in the string builder does not exceed
* the capacity, it is not necessary to allocate a new internal
* buffer. If the internal buffer overflows, it is automatically made larger.
*
* <p>Instances of <code>StringBuilder</code> are not safe for
* use by multiple threads. If such synchronization is required then it is
* recommended that {@link java.lang.StringBuffer} be used.
0 0
- StringBuffer与StringBuilder区别
- StringBuilder 与 StringBuffer 区别
- StringBuffer与StringBuilder区别
- StringBuffer与StringBuilder区别
- StringBuffer与StringBuilder 区别
- StringBuffer 与StringBuilder 区别
- StringBuffer与StringBuilder区别
- StringBuffer与StringBuilder区别
- StringBuffer 与 StringBuilder的区别?
- StringBuilder与StringBuffer的区别
- StringBuffer 与 StringBuilder的区别
- StringBuffer与StringBUilder的区别
- StringBuffer与StringBuilder的区别
- StringBuilder与StringBuffer的区别
- StringBuilder与StringBuffer的区别
- StringBuilder与StringBuffer的区别
- StringBuilder与StringBuffer的区别
- StringBuilder与StringBuffer的区别
- windows 7 PostgreSQL服务因为无法登录而无法启动的解决办法
- 中文分词之Java实现使用IK Analyzer实现
- 增强for循环和for-each循环
- 数字信号处理的学习资源
- 神奇的sh:管道操作|原理 ,实现一个支持管道操作的grep
- StringBuilder 与 StringBuffer 区别
- 【LeetCode with Python】 Combinations
- Directx10 龙书笔记- 雾效的实现
- MariaDB Galera Cluster 5.5.39 on Centos 5.8_64
- 【LeetCode with Python】 Convert Sorted Array to Binary Search Tree
- 【LeetCode with Python】 Copy List with Random Pointer
- 位域之我见
- 【LeetCode with Python】 Count and Say
- 《炉石传说》架构设计赏析(3):Gameplay初探