假设字符串a和b:
a += b
a = a.concat(b)
Run Code Online (Sandbox Code Playgroud)
引擎盖下,它们是一样的吗?
这里以concat反编译为参考.我希望能够反编译+运算符以查看它的作用.
public String concat(String s) {
int i = s.length();
if (i == 0) {
return this;
}
else {
char ac[] = new char[count + i];
getChars(0, count, ac, 0);
s.getChars(0, i, ac, count);
return new String(0, count + i, ac);
}
}
Run Code Online (Sandbox Code Playgroud)