Angenommen, String a und b:
a += b
a = a.concat(b)
Sind sie unter der Haube dasselbe?
Hier ist concat als Referenz dekompiliert. Ich würde gerne die Dekompilierung der +
Operator, um zu sehen, was das bewirkt.
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);
}
}