FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
toBeTopJavaer/basics/java-basic/string-append.md at master · SuperDCode/toBeTopJavaer · GitHub
SuperDCode
/
toBeTopJavaer
Public
forked from
hollischuang/toBeTopJavaer
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
toBeTopJavaer
/
basics
/
java-basic
/
string-append.md
Copy path
More file actions
More file actions
Latest commit
History
History
History
3 lines (2 loc) · 308 Bytes
Breadcrumbs
toBeTopJavaer
/
basics
/
java-basic
/
string-append.md
Copy path
File metadata and controls
3 lines (2 loc) · 308 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
1.
String
s
=
"a"
+
"b"
,
编译器会进行常量折叠
(
因为两个都是编译期常量
,
编译期可知
),
即变成
String
s
=
"ab"
2.
对于能够进行优化的
(
String
s
=
"a"
+
变量
等
)
用
StringBuilder
的
append
()
方法替代
,
最后调用
toString
()
方法
(
底层就是一个
new
String
())
Back
|
FazBrowse Home
|
New Git URL