Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringBuffer,StringBuilder 中的描述问题 #1434

Closed
debugjoker opened this issue Oct 24, 2021 · 2 comments
Closed

StringBuffer,StringBuilder 中的描述问题 #1434

debugjoker opened this issue Oct 24, 2021 · 2 comments
Labels
bug Content error

Comments

@debugjoker
Copy link
Contributor

原文如下:

补充(来自issue 675):在 Java 9 之后,String 、StringBuilderStringBuffer 的实现改用 byte 数组存储字符串 private final byte[] value

源码中的变量是改用了byte数组,但是不是final修饰的啊,写错了吧这里

    /**
     * The value is used for character storage.
     */
    byte[] value;

    /**
     * The id of the encoding used to encode the bytes in {@code value}.
     */
    byte coder;

    /**
     * The count is the number of characters used.
     */
    int count;

    private static final byte[] EMPTYVALUE = new byte[0];
@debugjoker
Copy link
Contributor Author

这描述的有歧义,建议改成下面这样

String 、StringBuilder 与 StringBuffer 的底层实现均改用 byte 数组存储字符串

只有String底层是final修饰,StringBuilder 与 StringBuffer 没有,容易歧义

@Snailclimb Snailclimb added the 待处理 待处理的issue/pr label Oct 26, 2021
@Snailclimb Snailclimb removed the 待处理 待处理的issue/pr label Jan 19, 2022
@Snailclimb
Copy link
Owner

原文如下:

补充(来自issue 675):在 Java 9 之后,String 、StringBuilderStringBuffer 的实现改用 byte 数组存储字符串 private final byte[] value

源码中的变量是改用了byte数组,但是不是final修饰的啊,写错了吧这里

    /**
     * The value is used for character storage.
     */
    byte[] value;

    /**
     * The id of the encoding used to encode the bytes in {@code value}.
     */
    byte coder;

    /**
     * The count is the number of characters used.
     */
    int count;

    private static final byte[] EMPTYVALUE = new byte[0];

已经修复👍

@Snailclimb Snailclimb added the bug Content error label Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Content error
Projects
None yet
Development

No branches or pull requests

2 participants