
Shao X. answered 04/14/19
I am a software engineer at Amazon
In the nutshell, they are the same, copying char[] from input the current char array.
char buf[] = Arrays.copyOf(value, len + otherLen);
For the + operator, the compiler converts "x = "+x;
into a StringBuilder
internally and uses .append(int)
to "add" the integer to the string. If you look at the append implementation, it's copying compiled char array.
System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);