hollischuang / toBeTopJavaer

To Be Top Javaer - Java工程师成神之路
https://www.hollischuang.com
25.31k stars 5.47k forks source link

請問字串+串接編譯後的問題 #76

Closed grieve54706 closed 4 years ago

grieve54706 commented 4 years ago

因 "String对“+”的重载" 提到

String s = "a" + "b" 

都是常數會變成

String s = "ab"

但在 "字符串拼接" 章節提到

String wechat = "Hollis";
String introduce = "每日更新Java相关技术文章";
String hollis = wechat + "," + introduce;

在jad會變成

String hollis = (new StringBuilder()).append(wechat).append(",").append(introduce).toString();

好像跟前者有落差 而且改用Procyon跟Fernflower都會是

this.hollis = this.wechat + "," + this.introduce;