Home  >  Article  >  Java  >  Detailed explanation of the use of append() method in java

Detailed explanation of the use of append() method in java

hzc
hzcOriginal
2020-06-18 13:58:2427526browse

Detailed explanation of the use of append() method in java

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn