<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sung in Blog

               一些技術文章 & 一些生活雜碎

    java.lang
    Class StringBuffer

    java.lang.Object
      |
      +--java.lang.StringBuffer
    
    All Implemented Interfaces:
    CharSequence, Serializable

    public final class StringBuffer
    extends Object
    implements Serializable, CharSequence

    A string buffer implements a mutable sequence of characters. A string buffer is like a String, 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 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.

    String buffers are used by the compiler to implement the binary string concatenation operator +. For example, the code:

         x = "a" + 4 + "c"
     

    is compiled to the equivalent of:

         x = new StringBuffer().append("a").append(4).append("c")
                               .toString()
     
    which creates a new string buffer (initially empty), appends the string representation of each operand to the string buffer in turn, and then converts the contents of the string buffer to a string. Overall, this avoids creating many temporary strings.

    The principal operations on a StringBuffer are the append and insert 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 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).

    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 new internal buffer array. If the internal buffer overflows, it is automatically made larger.

    Since:
    JDK1.0
    See Also:
    ByteArrayOutputStream, String, Serialized Form
    posted on 2005-10-26 14:26 Sung 閱讀(331) 評論(1)  編輯  收藏 所屬分類: Java

    FeedBack:
    # re: Class StringBuffer
    2005-10-26 14:43 | Sung
    Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared.  回復  更多評論
      
    主站蜘蛛池模板: 最刺激黄a大片免费网站| 久久国产免费一区二区三区| 青青青免费国产在线视频小草| 日本精品久久久久久久久免费| 美女一级毛片免费观看| 最近中文字幕免费mv视频8| 亚洲av片不卡无码久久| 24小时日本韩国高清免费| 久久精品国产亚洲AV高清热| 999任你躁在线精品免费不卡| 黄a大片av永久免费| 亚洲黄页网在线观看| 日韩一区二区免费视频| 亚洲乱码av中文一区二区| 在线观看亚洲免费| 色吊丝性永久免费看码 | 2020因为爱你带字幕免费观看全集| 免费毛片在线看片免费丝瓜视频| 国产综合亚洲专区在线| 中文字幕的电影免费网站| 亚洲男人天堂av| 中文字幕无码不卡免费视频| 亚洲AV无码专区亚洲AV桃| 亚洲综合色区在线观看| 国产v亚洲v天堂无码网站| 久久久精品2019免费观看| 亚洲人成免费网站| 日韩一级免费视频| 两个人看的www高清免费视频| 免费h黄肉动漫在线观看| 亚洲精品亚洲人成在线麻豆| 在线免费观看一级毛片| 产传媒61国产免费| 久久精品蜜芽亚洲国产AV| 免费涩涩在线视频网| 老司机精品免费视频| 亚洲男人的天堂久久精品| 亚洲第一区精品日韩在线播放| 亚洲五月丁香综合视频| 亚洲国产高清精品线久久| 最近中文字幕电影大全免费版|