-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ start.sh | |
setting.sh | ||
docs/.vuepress/styles/palette.scss | ||
docs/.vuepress/dist | ||
commitlint.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# String | ||
|
||
``` | ||
private final char value[]; | ||
``` | ||
|
||
在循环里字符串拼接不要用+,要用StringBuilder。 | ||
|
||
![image-20240128093814484](https://csnotes.oss-cn-beijing.aliyuncs.com/photos/image-20240128093814484.png) | ||
|
||
String不能用String[0]取数。 | ||
|
||
要用String.charAt[0]取数。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# StringBuffer | ||
|
||
char[] value; | ||
|
||
可以改值。减少内存消耗 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# final关键字 | ||
|
||
final定义的字段必须在构造对象时初始化,也就是常量。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# static关键字 | ||
|
||
static关键字用于把所有的对象用同一块内存存起来。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# String类 | ||
|
||
String类是个final类,不能被其他类继承。 | ||
|
||
```java | ||
public static void main(String[] args) { | ||
String name = "NU"; | ||
name = "tom"; | ||
final char[] value = {'a', 'b', 'c'}; | ||
char[] v2={'a','b','c'}; | ||
value[0] = 'd'; | ||
value=v2;//报错,因为value是final的,不能改地址。 | ||
} | ||
``` | ||
|
||
``` | ||
String s = "hdp"; | ||
String s = new String("qwe"); | ||
``` | ||
|
||
``` | ||
public static void main(String[] args) { | ||
//a指向常量池中的"abc" | ||
String a = "abc"; | ||
String b = "abc"; | ||
//a和b的值相等 | ||
System.out.println(a.equals(b));//true | ||
//a和b指向同一个对象 | ||
System.out.println(a == b);//true | ||
} | ||
``` | ||
|
||
``` | ||
public static void main(String[] args) { | ||
//a指向常量池中的"abc" | ||
String a = "abc"; | ||
String b = "de"; | ||
String c = a + b | ||
//StringBuilder sb = new StringBuilder(); | ||
//sb.append("abc"); | ||
/sb.append("de"); | ||
//String c = sb.toString(); | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# 刷题工具 | ||
|
||
LeetCode+Idea | ||
LeetCode+VSCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters