Java源码-AbstractStringBuilder

来源:互联网 发布:9.9天天特价淘宝 编辑:程序博客网 时间:2024/06/05 04:18
    /**     * The value is used for character storage.     */    char[] value;    /**     * The count is the number of characters used.     */    int count;

这是此类的两个成员变量,value是存储字符用的,value.length表示字符容量。
count表示已经使用的长度。
对应的方法:
    /**     * 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;    }


0 0
原创粉丝点击