Detailed explanation of the use of the append() method in Java:
The append() method in Java actually creates a new array. Expand the length and copy the string that needs to be added to this new array.
Stringbuffer in JAVA has the append() method:
Stringbuffer is a dynamic string array, and append() is to add to the dynamic string array, which is equivalent to "xxxx" "yyyy"' ' Number.
The difference from String is that Stringbuffer is put together. Although String1 String2 and Stringbuffer1.append("yyyy") have the same printing effect, they are represented differently in memory.
String1 String2 Exist in two different address memories, Stringbuffer1.append(Stringbuffer2) put them together.
StringBuffer is thread-safe and mostly used for multi-threading.
Recommended tutorial: "java tutorial"
The above is the detailed content of Detailed explanation of the use of append() method in java. For more information, please follow other related articles on the PHP Chinese website!