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

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

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

    Sung in Blog

               一些技術(shù)文章 & 一些生活雜碎

    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.  回復(fù)  更多評論
      
    主站蜘蛛池模板: a级成人免费毛片完整版| 免费一级毛片在线播放放视频| av永久免费网站在线观看| 亚洲精品国自产拍在线观看| 美女黄色免费网站| 不卡精品国产_亚洲人成在线| sss日本免费完整版在线观看| 国产午夜亚洲精品理论片不卡 | 亚洲精品第一国产综合野| 57PAO成人国产永久免费视频| 亚洲一级毛片免费看| 最近最好的中文字幕2019免费| 亚洲av无码一区二区三区天堂| 在线观着免费观看国产黄| 成人国产网站v片免费观看 | 亚洲欧洲日韩国产综合在线二区| 91香焦国产线观看看免费| 亚洲福利电影一区二区?| 啦啦啦高清视频在线观看免费| 亚洲欧洲无卡二区视頻| 日韩成人免费视频播放| 91国内免费在线视频| 亚洲精品国产专区91在线| 欧美在线看片A免费观看| 免费在线观看亚洲| 黑人精品videos亚洲人| 亚洲黄色免费在线观看| 亚洲欧洲专线一区| 亚洲精品国产美女久久久| 91精品视频免费| 一级中文字幕乱码免费| 在线观看亚洲人成网站| 女人18毛片水真多免费看| 又粗又长又爽又长黄免费视频| 亚洲AV福利天堂一区二区三| 午夜dj在线观看免费视频| 中国在线观看免费的www| 亚洲丝袜中文字幕| 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 | 91在线视频免费观看| 亚洲国产理论片在线播放|