StringBuffer与StringBuilder的相同之处

大致方法相同: 构造器相同 相同方法名称的不同:这个是线程安全方法上加了synchronized

StringBuffer方法不同之处

因为他是线程安全的所以他重写了很多父类的方法 也没什么好说的 基本上类似
  public synchronized int codePointBefore(int index) {
        return super.codePointBefore(index);
    }
  public synchronized int codePointCount(int beginIndex, int endIndex) {
        return super.codePointCount(beginIndex, endIndex);
    }
    public synchronized void ensureCapacity(int minimumCapacity) {
        super.ensureCapacity(minimumCapacity);
    }
    public synchronized void trimToSize() {
        super.trimToSize();
    }

相关文章:

  • 2022-01-27
  • 2021-09-12
  • 2022-12-23
  • 2021-06-05
  • 2022-01-16
  • 2021-06-24
  • 2022-02-19
猜你喜欢
  • 2022-01-10
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
相关资源
相似解决方案