If you have the string a, b in Java, you can connect it
a+=b
a.concat(b)
There's a way like this. Are these two the same? I have the code for the concat method, but there is no code for + operator. Please show me the code if possible. And I want to know how the + operator works.
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);
}
}
The concat method and + operator are not the same. For the first reason, if you do a.concat(b) when a is null, you will face a null PointerException. But a+=b; works well even if a is null. Also, the concat method only allows the String value + operator is available if the factor can be converted to String.
So the concat method is more restrictive than the + operator.
534 Uncaught (inpromise) Error on Electron: An object could not be cloned
547 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
702 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.