zoukankan      html  css  js  c++  java
  • StringBuffer StringBuilder append

    StringBuilder is not thread safe. So, it performs better in situations where thread safety is not required.

    StringBuffer is implemented by using synchronized keyword on all methods.

    StringBuffer

    /*      */   public synchronized StringBuffer append(String string)
    /*      */   {
    /*  197 */     if (string == null) string = String.valueOf(string);
    /*  198 */     int adding = string.length();
    /*  199 */     int newSize = this.count + adding;
    /*  200 */     if (newSize > this.value.length) {
    /*  201 */       ensureCapacityImpl(newSize);
    /*      */     }
    /*  203 */     string.getChars(0, adding, this.value, this.count);
    /*  204 */     this.count = newSize;
    /*  205 */     return this;
    /*      */   }

    StringBuilder

    /*      */   public StringBuilder append(String string)
    /*      */   {
    /*  201 */     if (string == null) string = String.valueOf(string);
    /*  202 */     int adding = string.length();
    /*  203 */     int newSize = this.count + adding;
    /*  204 */     if (newSize > this.value.length) {
    /*  205 */       ensureCapacityImpl(newSize);
    /*      */     }
    /*  207 */     string.getChars(0, adding, this.value, this.count);
    /*  208 */     this.count = newSize;
    /*  209 */     return this;
    /*      */   }
  • 相关阅读:
    h5移动开发css
    js 小数相加异常
    h5上滑刷新(分页)
    js中的 !!
    图片懒加载(延迟加载)原理及实现
    作用域内优先级及this指针
    函数的属性、方法和构造函数
    判断是否为严格模式
    匿名函数递归调用自身
    闭包
  • 原文地址:https://www.cnblogs.com/kakaisgood/p/6604015.html
Copyright © 2011-2022 走看看