Skip to content

Commit

Permalink
doc: update java.md (#914)
Browse files Browse the repository at this point in the history
* method intern can get a ref of the same string in the string pool

* doc: update java.md
  • Loading branch information
ri-fumo authored Jan 2, 2025
1 parent ad9aaf7 commit 3bcb61d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,12 @@ sb.append("!");
### 比较

```java
String s1 = new String("QuickRef");
String s1 = "QuickRef";
String s2 = new String("QuickRef");
s1 == s2 // false
s1.equals(s2) // true
s1 == s2 // false
s1.equals(s2) // true
// intern 方法获得字符串常量池中的惟一引用
s1 == s2.intern() // true
"AB".equalsIgnoreCase("ab") // true
```

Expand Down Expand Up @@ -310,7 +312,7 @@ int[] a3 = new int[]{1, 2, 3};
int[] a4 = new int[3];
a4[0] = 1;
a4[2] = 2;
a4[3] = 3;
a4[3] = 3; // 会出现索引越界异常
```

### 修改 Modify
Expand Down

0 comments on commit 3bcb61d

Please sign in to comment.