File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -1008,9 +1008,11 @@ public class Student {
10081008
10091009#### 2.5 . 1. String StringBuffer 和 StringBuilder 的区别是什么? String 为什么是不可变的?
10101010
1011+ ** 可变性**
1012+
10111013简单的来说:`String ` 类中使用 final 关键字修饰字符数组来保存字符串,`private final char value[]`,所以`String ` 对象是不可变的。
10121014
1013- > 补充(来自[issue 675 ](https: // github.com/Snailclimb/JavaGuide/issues/675)):在 Java 9 之后,String 类的实现改用 byte 数组存储字符串 `private final byte[] value`;
1015+ > 补充(来自[issue 675 ](https: // github.com/Snailclimb/JavaGuide/issues/675)):在 Java 9 之后,String 、`StringBuilder` 与 `StringBuffer` 的实现改用 byte 数组存储字符串 `private final byte[] value`
10141016
10151017而 `StringBuilder ` 与 `StringBuffer ` 都继承自 `AbstractStringBuilder ` 类,在 `AbstractStringBuilder ` 中也是使用字符数组保存字符串`char[] value` 但是没有用 `final ` 关键字修饰,所以这两种对象都是可变的。
10161018
You can’t perform that action at this time.
0 commit comments