The detailed annotation of StringBuilder

Source: Internet
Author: User

Tag: seq equals tar so enc. com Val pac pairs

capacity ()
returns the current capacity. Capacity refers to the amount of storage that can be used for the most recent insertion character, which needs to be reassigned.

Return:
current capacity.
public
int length()
returns the length (number of characters).

Designated by:
CharSequence in the interface length .
Return:
The length of the
current character sequence represented by this object.
The
capacity is the theoretical value, the length is the actual value.
Append
Appends the string representation of any type parameter to the sequence.
String.valueOfmethod is the same. The characters in the resulting string are then appended to this sequence.
Reverse
Reverse ()
This sequence of characters is replaced with its inverse form. If there is a surrogate pair (surrogate pair) in the sequence, it is treated as a single character in the reverse operation. Therefore, the order of the high-low surrogate is not reversed. Assuming that N is the character reverse length (not the length of the value) of the character sequence before the method is executed char , the character at index K in the new character sequence will be equal to the word at the original character sequence index n-k-1 Character.

Note that after the reverse operation, low and high surrogate entries that are not paired before the action is performed will become surrogate pairs. For example, reversing "\udc00\ud800" will generate a valid surrogate pair "\UD800\UDC00".

Return:
a reference to this object.
Here is someone who might ask what is a surrogate pair? A detailed explanation is given below.
the literal meaning is: the proxy pair. In effect, a UTF16 encoding is replaced by a two UTF16 encoding instead.
The estimation of translation can be: UTF16 encoding agent pair.

Why do I need surrogate pairs? The original character is represented by a UTF16 encoding (two bytes), but because of the increasing number of characters that need to be encoded, only one UTF16 encoding is not enough to represent all characters. Therefore, it is necessary to consider using 2 UTF16 to represent one character (four bytes). But if all the characters are encoded this way, too much space (originally only need 2 bytes, now instead of 4 bytes), so that only use two a certain range of UTF16 encoding is considered a set of surrogate pairs, which is used to represent a character, For the rest of the situation, a UTF16 is used to represent a character.

The detailed annotation of StringBuilder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.