String (Java Platform SE 8 ) (original) (raw)

Modifier and Type

Method

Description

char

[charAt](../../java/lang/String.html#charAt-int-)(int index)

Returns the char value at the specified index.

int

[codePointAt](../../java/lang/String.html#codePointAt-int-)(int index)

Returns the character (Unicode code point) at the specified index.

int

[codePointBefore](../../java/lang/String.html#codePointBefore-int-)(int index)

Returns the character (Unicode code point) before the specified index.

int

[codePointCount](../../java/lang/String.html#codePointCount-int-int-)(int beginIndex, int endIndex)

Returns the number of Unicode code points in the specified text range of this String.

int

[compareTo](../../java/lang/String.html#compareTo-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") anotherString)

Compares two strings lexicographically.

int

[compareToIgnoreCase](../../java/lang/String.html#compareToIgnoreCase-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") str)

Compares two strings lexicographically, ignoring case differences.

[String](../../java/lang/String.html "class in java.lang")

[concat](../../java/lang/String.html#concat-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") str)

Concatenates the specified string to the end of this string.

boolean

[contains](../../java/lang/String.html#contains-java.lang.CharSequence-)([CharSequence](../../java/lang/CharSequence.html "interface in java.lang") s)

Returns true if and only if this string contains the specified sequence of char values.

boolean

[contentEquals](../../java/lang/String.html#contentEquals-java.lang.CharSequence-)([CharSequence](../../java/lang/CharSequence.html "interface in java.lang") cs)

Compares this string to the specified CharSequence.

boolean

[contentEquals](../../java/lang/String.html#contentEquals-java.lang.StringBuffer-)([StringBuffer](../../java/lang/StringBuffer.html "class in java.lang") sb)

Compares this string to the specified StringBuffer.

static [String](../../java/lang/String.html "class in java.lang")

[copyValueOf](../../java/lang/String.html#copyValueOf-char:A-)(char[] data)

static [String](../../java/lang/String.html "class in java.lang")

[copyValueOf](../../java/lang/String.html#copyValueOf-char:A-int-int-)(char[] data, int offset, int count)

boolean

[endsWith](../../java/lang/String.html#endsWith-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") suffix)

Tests if this string ends with the specified suffix.

boolean

[equals](../../java/lang/String.html#equals-java.lang.Object-)([Object](../../java/lang/Object.html "class in java.lang") anObject)

Compares this string to the specified object.

boolean

[equalsIgnoreCase](../../java/lang/String.html#equalsIgnoreCase-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") anotherString)

Compares this String to another String, ignoring case considerations.

static [String](../../java/lang/String.html "class in java.lang")

[format](../../java/lang/String.html#format-java.util.Locale-java.lang.String-java.lang.Object...-)([Locale](../../java/util/Locale.html "class in java.util") l,[String](../../java/lang/String.html "class in java.lang") format,[Object](../../java/lang/Object.html "class in java.lang")... args)

Returns a formatted string using the specified locale, format string, and arguments.

static [String](../../java/lang/String.html "class in java.lang")

[format](../../java/lang/String.html#format-java.lang.String-java.lang.Object...-)([String](../../java/lang/String.html "class in java.lang") format,[Object](../../java/lang/Object.html "class in java.lang")... args)

Returns a formatted string using the specified format string and arguments.

byte[]

[getBytes](../../java/lang/String.html#getBytes--)()

Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.

byte[]

[getBytes](../../java/lang/String.html#getBytes-java.nio.charset.Charset-)([Charset](../../java/nio/charset/Charset.html "class in java.nio.charset") charset)

Encodes this String into a sequence of bytes using the givencharset, storing the result into a new byte array.

void

[getBytes](../../java/lang/String.html#getBytes-int-int-byte:A-int-)(int srcBegin, int srcEnd, byte[] dst, int dstBegin)

byte[]

[getBytes](../../java/lang/String.html#getBytes-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") charsetName)

Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array.

void

[getChars](../../java/lang/String.html#getChars-int-int-char:A-int-)(int srcBegin, int srcEnd, char[] dst, int dstBegin)

Copies characters from this string into the destination character array.

int

[hashCode](../../java/lang/String.html#hashCode--)()

Returns a hash code for this string.

int

[indexOf](../../java/lang/String.html#indexOf-int-)(int ch)

Returns the index within this string of the first occurrence of the specified character.

int

[indexOf](../../java/lang/String.html#indexOf-int-int-)(int ch, int fromIndex)

Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.

int

[indexOf](../../java/lang/String.html#indexOf-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") str)

Returns the index within this string of the first occurrence of the specified substring.

int

[indexOf](../../java/lang/String.html#indexOf-java.lang.String-int-)([String](../../java/lang/String.html "class in java.lang") str, int fromIndex)

Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.

[String](../../java/lang/String.html "class in java.lang")

[intern](../../java/lang/String.html#intern--)()

Returns a canonical representation for the string object.

boolean

[isEmpty](../../java/lang/String.html#isEmpty--)()

Returns true if, and only if, length() is 0.

static [String](../../java/lang/String.html "class in java.lang")

[join](../../java/lang/String.html#join-java.lang.CharSequence-java.lang.CharSequence...-)([CharSequence](../../java/lang/CharSequence.html "interface in java.lang") delimiter,[CharSequence](../../java/lang/CharSequence.html "interface in java.lang")... elements)

Returns a new String composed of copies of theCharSequence elements joined together with a copy of the specified delimiter.

static [String](../../java/lang/String.html "class in java.lang")

[join](../../java/lang/String.html#join-java.lang.CharSequence-java.lang.Iterable-)([CharSequence](../../java/lang/CharSequence.html "interface in java.lang") delimiter,[Iterable](../../java/lang/Iterable.html "interface in java.lang")<? extends [CharSequence](../../java/lang/CharSequence.html "interface in java.lang")> elements)

Returns a new String composed of copies of theCharSequence elements joined together with a copy of the specified delimiter.

int

[lastIndexOf](../../java/lang/String.html#lastIndexOf-int-)(int ch)

Returns the index within this string of the last occurrence of the specified character.

int

[lastIndexOf](../../java/lang/String.html#lastIndexOf-int-int-)(int ch, int fromIndex)

Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index.

int

[lastIndexOf](../../java/lang/String.html#lastIndexOf-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") str)

Returns the index within this string of the last occurrence of the specified substring.

int

[lastIndexOf](../../java/lang/String.html#lastIndexOf-java.lang.String-int-)([String](../../java/lang/String.html "class in java.lang") str, int fromIndex)

Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.

int

[length](../../java/lang/String.html#length--)()

Returns the length of this string.

boolean

[matches](../../java/lang/String.html#matches-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") regex)

int

[offsetByCodePoints](../../java/lang/String.html#offsetByCodePoints-int-int-)(int index, int codePointOffset)

Returns the index within this String that is offset from the given index bycodePointOffset code points.

boolean

[regionMatches](../../java/lang/String.html#regionMatches-boolean-int-java.lang.String-int-int-)(boolean ignoreCase, int toffset,[String](../../java/lang/String.html "class in java.lang") other, int ooffset, int len)

Tests if two string regions are equal.

boolean

[regionMatches](../../java/lang/String.html#regionMatches-int-java.lang.String-int-int-)(int toffset,[String](../../java/lang/String.html "class in java.lang") other, int ooffset, int len)

Tests if two string regions are equal.

[String](../../java/lang/String.html "class in java.lang")

[replace](../../java/lang/String.html#replace-char-char-)(char oldChar, char newChar)

Returns a string resulting from replacing all occurrences ofoldChar in this string with newChar.

[String](../../java/lang/String.html "class in java.lang")

[replace](../../java/lang/String.html#replace-java.lang.CharSequence-java.lang.CharSequence-)([CharSequence](../../java/lang/CharSequence.html "interface in java.lang") target,[CharSequence](../../java/lang/CharSequence.html "interface in java.lang") replacement)

Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.

[String](../../java/lang/String.html "class in java.lang")

[replaceAll](../../java/lang/String.html#replaceAll-java.lang.String-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") regex,[String](../../java/lang/String.html "class in java.lang") replacement)

Replaces each substring of this string that matches the given regular expression with the given replacement.

[String](../../java/lang/String.html "class in java.lang")

[replaceFirst](../../java/lang/String.html#replaceFirst-java.lang.String-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") regex,[String](../../java/lang/String.html "class in java.lang") replacement)

Replaces the first substring of this string that matches the given regular expression with the given replacement.

[String](../../java/lang/String.html "class in java.lang")[]

[split](../../java/lang/String.html#split-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") regex)

[String](../../java/lang/String.html "class in java.lang")[]

[split](../../java/lang/String.html#split-java.lang.String-int-)([String](../../java/lang/String.html "class in java.lang") regex, int limit)

boolean

[startsWith](../../java/lang/String.html#startsWith-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") prefix)

Tests if this string starts with the specified prefix.

boolean

[startsWith](../../java/lang/String.html#startsWith-java.lang.String-int-)([String](../../java/lang/String.html "class in java.lang") prefix, int toffset)

Tests if the substring of this string beginning at the specified index starts with the specified prefix.

[CharSequence](../../java/lang/CharSequence.html "interface in java.lang")

[subSequence](../../java/lang/String.html#subSequence-int-int-)(int beginIndex, int endIndex)

Returns a character sequence that is a subsequence of this sequence.

[String](../../java/lang/String.html "class in java.lang")

[substring](../../java/lang/String.html#substring-int-)(int beginIndex)

Returns a string that is a substring of this string.

[String](../../java/lang/String.html "class in java.lang")

[substring](../../java/lang/String.html#substring-int-int-)(int beginIndex, int endIndex)

Returns a string that is a substring of this string.

char[]

[toCharArray](../../java/lang/String.html#toCharArray--)()

Converts this string to a new character array.

[String](../../java/lang/String.html "class in java.lang")

[toLowerCase](../../java/lang/String.html#toLowerCase--)()

Converts all of the characters in this String to lower case using the rules of the default locale.

[String](../../java/lang/String.html "class in java.lang")

[toLowerCase](../../java/lang/String.html#toLowerCase-java.util.Locale-)([Locale](../../java/util/Locale.html "class in java.util") locale)

Converts all of the characters in this String to lower case using the rules of the given Locale.

[String](../../java/lang/String.html "class in java.lang")

[toString](../../java/lang/String.html#toString--)()

This object (which is already a string!) is itself returned.

[String](../../java/lang/String.html "class in java.lang")

[toUpperCase](../../java/lang/String.html#toUpperCase--)()

Converts all of the characters in this String to upper case using the rules of the default locale.

[String](../../java/lang/String.html "class in java.lang")

[toUpperCase](../../java/lang/String.html#toUpperCase-java.util.Locale-)([Locale](../../java/util/Locale.html "class in java.util") locale)

Converts all of the characters in this String to upper case using the rules of the given Locale.

[String](../../java/lang/String.html "class in java.lang")

[trim](../../java/lang/String.html#trim--)()

Returns a string whose value is this string, with any leading and trailing whitespace removed.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-boolean-)(boolean b)

Returns the string representation of the boolean argument.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-char-)(char c)

Returns the string representation of the char argument.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-char:A-)(char[] data)

Returns the string representation of the char array argument.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-char:A-int-int-)(char[] data, int offset, int count)

Returns the string representation of a specific subarray of thechar array argument.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-double-)(double d)

Returns the string representation of the double argument.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-float-)(float f)

Returns the string representation of the float argument.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-int-)(int i)

Returns the string representation of the int argument.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-long-)(long l)

Returns the string representation of the long argument.

static [String](../../java/lang/String.html "class in java.lang")

[valueOf](../../java/lang/String.html#valueOf-java.lang.Object-)([Object](../../java/lang/Object.html "class in java.lang") obj)

Returns the string representation of the Object argument.