The following API annotations contain important methods in the StringBuilder class
append(boolean b): Append the string representation of the boolean parameter to the sequence .
Append(char c): Appends the string representation of the char parameter to this sequence.
Append(char[] str): Appends the string representation of the char array parameter to this sequence.
Append(char[] str, int offset, int len): Appends the string representation of the subarray of the char array parameter to this sequence.
Append(CharSequence s): Appends the specified character sequence to this Appendable.
Append(CharSequence s, int start, int end): Append the subsequence of the specified CharSequence to this sequence.
Append(double d): Appends the string representation of the double parameter to this sequence.
Append(float f): Appends the string representation of the float parameter to this sequence.
Append(int i): Appends the string representation of the int parameter to this sequence.
Append(long lng): Appends the string representation of the long parameter to this sequence.
Append(Object obj): Append the string representation of the Object parameter.
Append(String str): Append the specified string to this character sequence.
Append(StringBuffer sb): Append the specified StringBuffer to this sequence.
appendCodePoint(int codePoint): Appends the string representation of the codePoint parameter to this sequence.
capacity(): Returns the current capacity.
charAt(int index): Returns the char value at the specified index in this sequence.
codePointAt(int index): Returns the character (unified code point) at the specified index.
codePointBefore(int index): Returns the character before the specified index (unified code point).
codePointCount(int beginIndex, int endIndex): Returns the unified code points within the specified text range of this sequence.
Delete(int start, int end): Remove characters from the substring of this sequence.
deleteCharAt(int index): Remove the char at the specified position in this sequence.
ensureCapacity(int minimumCapacity): Ensure that the capacity is at least equal to the specified minimum value.
getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin): Copy characters from this sequence to the target character array dst.
IndexOf(String str): Returns the index of the first occurrence of the specified substring in the string.
IndexOf(String str, int fromIndex): Starting from the specified index, return the index of the first occurrence of the specified substring in the string.
insert(int offset, boolean b): Insert the string representation of the boolean parameter into this sequence.
insert(int offset, char c): Inserts the string representation of the char parameter into this sequence.
insert(int offset, char[] str): Inserts the string representation of the char array parameter into this sequence.
insert(int index, char[] str, int offset, int len): Insert the string representation of the array parameter str subarray into this sequence.
insert(int dstOffset, CharSequence s): Insert the specified CharSequence into this sequence.
insert(int dstOffset, CharSequence s, int start, int end): Insert the subsequence of the specified CharSequence into this sequence.
insert(int offset, double d): Insert the string representation of the double parameter into this sequence.
insert(int offset, float f): Inserts the string representation of the float parameter into this sequence.
insert(int offset, int i): Inserts the string representation of the int parameter into this sequence.
insert(int offset, long l): Insert the string representation of the long parameter into this sequence.
insert(int offset, Object obj): Insert the string representation of the Object parameter into this character sequence.
insert(int offset, String str): Insert a string into this character sequence.
lastIndexOf(String str): Returns the index of the rightmost specified substring in this string.
lastIndexOf(String str, int fromIndex): Returns the index of the last occurrence of the specified substring in this string.
length(): Returns the length (number of characters).
offsetByCodePoints(int index, int codePointOffset): Returns an index in this sequence that is offset by codePointOffset code points from the given index.
Replace(int start, int end, String str): Replace the characters in the substring of this sequence with the characters in the given String.
Reverse(): Replace this character sequence with its reversed form.
setCharAt(int index, char ch): Sets the character at the given index to ch.
setLength(int newLength): Set the length of the character sequence.
subSequence(int start, int end): Returns a new character sequence that is a subsequence of this sequence.
substring(int start): Returns a new String that contains the subsequence of characters currently contained in this character sequence.
Substring(int start, int end): Returns a new String that contains a subsequence of characters currently contained in this sequence.
toString(): Returns the string representation of the data in this sequence.
trimToSize(): Try to reduce the storage space used for character sequences.
The above is the detailed content of Important methods in StringBuilder class. For more information, please follow other related articles on the PHP Chinese website!

StringBuilder类的append()方法接受String值并将其添加到当前对象。将字符串值转换为StringBuilder对象-获取字符串值。附加使用append()方法将字符串获取到StringBuilder。示例在下面的Java程序中,我们是将字符串数组转换为单个StringBuilder对象。 实时演示publicclassStringToStringBuilder{ publicstaticvoidmain(Stringargs[]){&a

使用java的StringBuilder.replace()函数替换指定范围的字符在Java中,StringBuilder类提供了replace()方法,可以用来替换字符串中指定范围的字符。该方法的语法如下:publicStringBuilderreplace(intstart,intend,Stringstr)上面的方法用于替换从索引star

stringbuilder清空的方法有:1、使用setLength(0)方法清空StringBuilder对象;2、使用delete(0, length)方法清空StringBuilder对象;3、使用replace(0, length, "")方法清空StringBuilder对象;4、使用new StringBuilder()重新创建一个新的StringBuilder对象。

Java中使用StringBuilder类的delete()方法删除字符串中的部分内容String类是Java中常用的字符串处理类,它具有很多常用的方法可用于字符串的操作。然而,在某些情况下,我们需要对字符串进行频繁的修改,而String类的不可变性会导致频繁的创建新的字符串对象,从而影响性能。为了解决这个问题,Java提供了StringBuilder类,它

Java文档解读:StringBuilder类的substring()方法详细介绍引言:在Java编程中,字符串的处理是非常常见的操作之一。而Java提供了一系列关于字符串处理的类和方法,其中StringBuilder类是常用于频繁字符串操作的选择。在StringBuilder类中,substring()方法是一个非常有用的方法,用于截取字符串的子串。本文将

Java如何使用StringBuilder类的substring()函数截取字符串的子串在Java中,我们经常需要处理字符串的操作。而Java的StringBuilder类提供了一系列的方法,方便我们对字符串进行操作。其中,substring()函数可以用于截取字符串的子串。substring()函数有两种重载形式,分别是substring(intstar

使用Java的StringBuilder.indexOf()函数查找子字符串在字符串缓冲区中的位置字符串操作是编程中常用的操作之一,而在Java中,我们经常使用的类是StringBuilder。StringBuilder是Java中可变的字符串序列,它提供了丰富的方法来对字符串进行编辑、连接和操作。在字符串操作中,有时我们需要查找某个子字符串在字符串缓冲区中

Java如何使用StringBuilder类的insert()函数在指定位置插入字符串在Java编程中,String类是不可变类,这意味着一旦创建了一个字符串对象,就无法改变它的值。然而,在实际开发中,我们有时需要在一个字符串中插入另一个字符串。为了实现这个功能,Java提供了StringBuilder类。StringBuilder是可变类,它允许我们在已有


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
