---
title: "Java源码-AbstractStringBuilder"
author: "DanielHan"
date: "2014-02-17T13:45:14Z"
tags: []
categories: ["编程语言"]
slug: "java-abstractstringbuilder"
draft: false
lastmod: "2014-02-15T17:32:40Z"
id: 2017605
url: "https://danielhan.iteye.com/blog/2017605"
---

```java

    /**
     * The value is used for character storage.
     */
    char[] value;

    /**
     * The count is the number of characters used.
     */
    int count;

```

这是此类的两个成员变量，value是存储字符用的，value.length表示字符容量。
count表示已经使用的长度。
对应的方法：

```java

    /**
     * Returns the length (character count).
     *
     * @return  the length of the sequence of characters currently
     *          represented by this object
     */
    public int length() {
        return count;
    }

    /**
     * Returns the current capacity. The capacity is the amount of storage
     * available for newly inserted characters, beyond which an allocation
     * will occur.
     *
     * @return  the current capacity
     */
    public int capacity() {
        return value.length;
    }

```