Top Description Inners Fields Constructors Methods
java.lang

public final Class String

extends Object
implements Serializable, Comparable<String>, CharSequence, Constable, ConstantDesc
Class Inheritance
All Implemented Interfaces
java.lang.constant.ConstantDesc, java.lang.constant.Constable, java.lang.CharSequence, java.lang.Comparable, java.io.Serializable
Imports
java.io.ObjectStreamField, .UnsupportedEncodingException, java.lang.annotation.Native, java.lang.foreign.MemorySegment, .ValueLayout, java.lang.invoke.MethodHandles, java.lang.constant.Constable, .ConstantDesc, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.*, java.util.ArrayList, .Arrays, .Comparator, .Formatter, .List, .Locale, .Objects, .Optional, .Spliterator, java.util.function.Function, java.util.regex.Pattern, .PatternSyntaxException, java.util.stream.Collectors, .IntStream, .Stream, .StreamSupport, jdk.internal.util.ArraysSupport, .Preconditions, jdk.internal.vm.annotation.ForceInline, .IntrinsicCandidate, .Stable, sun.nio.cs.ArrayDecoder, .ArrayEncoder, .ISO_8859_1, .US_ASCII, .UTF_8

The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class.

Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:

    String str = "abc";

is equivalent to:

    char data[] = {'a', 'b', 'c'};
    String str = new String(data);

Here are some more examples of how strings can be used:

    System.out.println("abc");
    String cde = "cde";
    System.out.println("abc" + cde);
    String c = "abc".substring(2, 3);
    String d = cde.substring(1, 2);

The class String includes methods for examining individual characters of the sequence, for comparing strings, for searching strings, for extracting substrings, and for creating a copy of a string with all characters translated to uppercase or to lowercase. Case mapping is based on the Unicode Standard version specified by the Character class.

The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. For additional information on string concatenation and conversion, see The Java Language Specification.

Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.

A String represents a string in the UTF-16 format in which supplementary characters are represented by surrogate pairs (see the section Unicode Character Representations in the Character class for more information). Index values refer to char code units, so a supplementary character uses two positions in a String.

The String class provides methods for dealing with Unicode code points (i.e., characters), in addition to those for dealing with Unicode code units (i.e., char values).

Unless otherwise noted, methods for comparing Strings do not take locale into account. The java.text.Collator class provides methods for finer-grain, locale-sensitive String comparison.

Implementation Note

The implementation of the string concatenation operator is left to the discretion of a Java compiler, as long as the compiler ultimately conforms to The Java Language Specification. For example, the javac compiler may implement the operator with StringBuffer, StringBuilder, or java.lang.invoke.StringConcatFactory depending on the JDK version. The implementation of string conversion is typically through the method toString, defined by Object and inherited by all classes in Java.

Authors
Lee Boynton, Arthur van Hoff, Martin Buchholz, Ulf Zibis
Since
1.0
Java Language Specification
15.18.1 String Concatenation Operator +
See Also
java.lang.Object#toString(), java.lang.StringBuffer, java.lang.StringBuilder, java.nio.charset.Charset

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
String.CaseInsensitiveComparator

CaseInsensitiveComparator for Strings.

Field Summary

Modifier and TypeField and Description
public static final Comparator<String>
CASE_INSENSITIVE_ORDER

A Comparator that orders String objects as by compareToIgnoreCase.

private final byte
coder

The identifier of the encoding used to encode the bytes in value.

pack-priv static final boolean
COMPACT_STRINGS

If String compaction is disabled, the bytes in value are always encoded in UTF16.

private int
hash

Cache the hash code for the string

private boolean
hashIsZero

Cache if the hash has been calculated as actually being zero, enabling us to avoid recalculating this.

pack-priv static final byte
private static final char
private static final ObjectStreamField[]
serialPersistentFields

Class String is special cased within the Serialization Stream Protocol.

private static final long
serialVersionUID

use serialVersionUID from JDK 1.0.2 for interoperability

pack-priv static final byte
private final byte[]
value

The value is used for character storage.

Constructor Summary

AccessConstructor and Description
public
String()

Initializes a newly created String object so that it represents an empty character sequence.

public
String(String
A String
original
)

Initializes a newly created String object so that it represents the same sequence of characters as the argument; in other words, the newly created string is a copy of the argument string.

public
String(char[]
The initial value of the string
value
)

Allocates a new String so that it represents the sequence of characters currently contained in the character array argument.

public
String(char[]
Array that is the source of characters
value
,
int
The initial offset
offset
,
int
The length
count
)

Allocates a new String that contains characters from a subarray of the character array argument.

public
String(int[]
Array that is the source of Unicode code points
codePoints
,
int
The initial offset
offset
,
int
The length
count
)

Allocates a new String that contains characters from a subarray of the Unicode code point array argument.

public
String(byte[]
The bytes to be converted to characters
ascii
,
int
The top 8 bits of each 16-bit Unicode code unit
hibyte
,
int
The initial offset
offset
,
int
The length
count
)
Deprecated since 1.1. This method does not properly convert bytes into characters.

Allocates a new String constructed from a subarray of an array of 8-bit integer values.

public
String(byte[]
The bytes to be converted to characters
ascii
,
int
The top 8 bits of each 16-bit Unicode code unit
hibyte
)
Deprecated since 1.1. This method does not properly convert bytes into characters.

Allocates a new String containing characters constructed from an array of 8-bit integer values.

public
String(byte[]
The bytes to be decoded into characters
bytes
,
int
The index of the first byte to decode
offset
,
int
The number of bytes to decode
length
,
String
The name of a supported charset
charsetName
)

Constructs a new String by decoding the specified subarray of bytes using the specified charset.

public
String(byte[]
The bytes to be decoded into characters
bytes
,
int
The index of the first byte to decode
offset
,
int
The number of bytes to decode
length
,
Charset
The charset to be used to decode the bytes
charset
)

Constructs a new String by decoding the specified subarray of bytes using the specified charset.

private
String(Charset charset, byte[] bytes, int offset, int length)

This method does not do any precondition checks on its arguments.

public
String(byte[]
The bytes to be decoded into characters
bytes
,
String
The name of a supported charset
charsetName
)

Constructs a new String by decoding the specified array of bytes using the specified charset.

public
String(byte[]
The bytes to be decoded into characters
bytes
,
Charset
The charset to be used to decode the bytes
charset
)

Constructs a new String by decoding the specified array of bytes using the specified charset.

public
String(byte[]
The bytes to be decoded into characters
bytes
,
int
The index of the first byte to decode
offset
,
int
The number of bytes to decode
length
)

Constructs a new String by decoding the specified subarray of bytes using the default charset.

public
String(byte[]
The bytes to be decoded into characters
bytes
)

Constructs a new String by decoding the specified array of bytes using the default charset.

public
String(StringBuffer
A StringBuffer
buffer
)

Allocates a new string that contains the sequence of characters currently contained in the string buffer argument.

public
String(StringBuilder
A StringBuilder
builder
)

Allocates a new string that contains the sequence of characters currently contained in the string builder argument.

private
String(char[] value, int off, int len, Void sig)

pack-priv
pack-priv
String(byte[] value, byte coder)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
public char

Returns:

the char value at the specified index of this string. The first char value is at index 0.
charAt
(int
the index of the char value.
index
)

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.

public IntStream

Returns:

an IntStream of char values from this sequence
chars
()

Overrides default java.lang.CharSequence.chars.

Returns a stream of int zero-extending the char values from this sequence.

pack-priv static void
checkBoundsBeginEnd(int begin, int end, int length)

pack-priv static int
checkBoundsOffCount(int offset, int count, int length)

pack-priv static void
checkIndex(int index, int length)

pack-priv static void
checkOffset(int offset, int length)

public int

Returns:

the code point value of the character at the index
codePointAt
(int
the index to the char values
index
)

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

public int

Returns:

the Unicode code point value before the given index.
codePointBefore
(int
the index following the code point that should be returned
index
)

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

public int

Returns:

the number of Unicode code points in the specified text range
codePointCount
(int
the index to the first char of the text range.
beginIndex
,
int
the index after the last char of the text range.
endIndex
)

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

public IntStream

Returns:

an IntStream of Unicode code points from this sequence
codePoints
()

Overrides default java.lang.CharSequence.codePoints.

Returns a stream of code point values from this sequence.

pack-priv byte
public int

Returns:

the value 0 if the argument string is equal to this string; a value less than 0 if this string is lexicographically less than the string argument; and a value greater than 0 if this string is lexicographically greater than the string argument.
compareTo
(String
the String to be compared.
anotherString
)

Implements java.lang.Comparable.compareTo.

Compares two strings lexicographically.

public int

Returns:

a negative integer, zero, or a positive integer as the specified String is greater than, equal to, or less than this String, ignoring case considerations.
compareToIgnoreCase
(String
the String to be compared.
str
)

Compares two strings lexicographically, ignoring case differences.

private static long

Returns:

the exact size required to UTF_8 encode this UTF16 string
computeSizeUTF8_UTF16
(byte[]
UTF16 encoded byte array
val
,
boolean
true to replace unmappable characters
doReplace
)

Returns the exact size required to UTF_8 encode this UTF16 string.

public String

Returns:

a string that represents the concatenation of this object's characters followed by the string argument's characters.
concat
(String
the String that is concatenated to the end of this String.
str
)

Concatenates the specified string to the end of this string.

public boolean

Returns:

true if this string contains s, false otherwise
contains
(CharSequence
the sequence to search for
s
)

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

public boolean

Returns:

true if this String represents the same sequence of characters as the specified StringBuffer, false otherwise
contentEquals
(StringBuffer
The StringBuffer to compare this String against
sb
)

Compares this string to the specified StringBuffer.

public boolean

Returns:

true if this String represents the same sequence of char values as the specified sequence, false otherwise
contentEquals
(CharSequence
The sequence to compare this String against
cs
)

Compares this string to the specified CharSequence.

pack-priv void
copyToSegmentRaw(MemorySegment segment, long offset)

public static String

Returns:

a String that contains the characters of the specified subarray of the character array.
copyValueOf
(char[]
the character array.
data
,
int
initial offset of the subarray.
offset
,
int
length of the subarray.
count
)

Equivalent to valueOf(char[], int, int).

public static String

Returns:

a String that contains the characters of the character array.
copyValueOf
(char[]
the character array.
data
)

Equivalent to valueOf(char[]).

private static char
decode2(int b1, int b2)

private static char
decode3(int b1, int b2, int b3)

private static int
decode4(int b1, int b2, int b3, int b4)

pack-priv static int

Returns:

the number of bytes successfully decoded, at most len
decodeASCII
(byte[] sa, int sp, char[] da, int dp, int len)

Decodes ASCII from the source byte array into the destination char array.

private static int
decodeUTF8_UTF16(byte[] src, int sp, int sl, byte[] dst, int dp, boolean doReplace)

private static int
decodeWithDecoder(CharsetDecoder cd, char[] dst, byte[] src, int offset, int length)

public Optional<String>

Returns:

an Optional describing the String instance
describeConstable
()

Implements java.lang.constant.Constable.describeConstable.

Returns an Optional containing the nominal descriptor for this instance, which is the instance itself.

private static byte[]
encode(Charset cs, byte coder, byte[] val)

private static byte[]
encode8859_1(byte coder, byte[] val)

private static byte[]
encode8859_1(byte coder, byte[] val, boolean doReplace)

private static byte[]
encodeASCII(byte coder, byte[] val)

private static byte[]
encodeUTF8(byte coder, byte[] val, boolean doReplace)

private static byte[]
encodeUTF8_UTF16(byte[] val, boolean doReplace)

private static byte[]
encodeWithEncoder(Charset cs, byte coder, byte[] val, boolean doReplace)

public boolean

Returns:

true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise. Note that the result will be true if the argument is the empty string or is equal to this String object as determined by the equals(Object) method.
endsWith
(String
the suffix.
suffix
)

Tests if this string ends with the specified suffix.

public boolean

Returns:

true if the given object represents a String equivalent to this string, false otherwise
equals
(Object
The object to compare this String against
anObject
)

Overrides java.lang.Object.equals.

Compares this string to the specified object.

public boolean

Returns:

true if the argument is not null and it represents an equivalent String ignoring case; false otherwise
equalsIgnoreCase
(String
The String to compare this String against
anotherString
)

Compares this String to another String, ignoring case considerations.

public static String

Returns:

A formatted string
format
(String format, Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

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

public static String

Returns:

A formatted string
format
(Locale
The locale to apply during formatting. If l is null then no localization is applied.
l
,
String format, Object...
Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification. The behaviour on a null argument depends on the conversion.
args
)

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

public String

Returns:

A formatted string
formatted
(Object...
Arguments referenced by the format specifiers in this string.
args
)

Formats using this string as the format string, and the supplied arguments.

public void
getBytes(int
Index of the first character in the string to copy
srcBegin
,
int
Index after the last character in the string to copy
srcEnd
,
byte[]
The destination array
dst
,
int
The start offset in the destination array
dstBegin
)
Deprecated since 1.1. This method does not properly convert characters into bytes.

Copies characters from this string into the destination byte array.

public byte[]

Returns:

The resultant byte array
getBytes
(String
The name of a supported charset
charsetName
)

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

public byte[]

Returns:

The resultant byte array
getBytes
(Charset
The java.nio.charset.Charset to be used to encode the String
charset
)

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

public byte[]

Returns:

The resultant byte array
getBytes
()

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

pack-priv void
getBytes(byte[] dst, int
the char index, not offset of byte[]
dstBegin
,
byte
the coder of dst[]
coder
)

Copy character bytes from this string into dst starting at dstBegin.

pack-priv void
getBytes(byte[] dst, int
the char index, not offset of byte[]
srcPos
,
int
the char index to start from
dstBegin
,
byte
the coder of dst[]
coder
,
int
the amount of copied chars
length
)

Copy character bytes from this string into dst starting at dstBegin.

pack-priv static byte[]
private static byte[]
pack-priv static byte[]
public void
getChars(int
index of the first character in the string to copy.
srcBegin
,
int
index after the last character in the string to copy.
srcEnd
,
char[]
the destination array.
dst
,
int
the start offset in the destination array.
dstBegin
)

Copies characters from this string into the destination character array.

public int

Returns:

a hash code value for this object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code for this string.

public String

Returns:

string with indentation adjusted and line endings normalized
indent
(int
number of leading white space characters to add or remove
n
)

Adjusts the indentation of each line of this string based on the value of n, and normalizes line termination characters.

public int

Returns:

the index of the first occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.
indexOf
(int
a character (Unicode code point).
ch
)

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

public int

Returns:

the index of the first occurrence of the character in the character sequence represented by this object that is greater than or equal to fromIndex, or -1 if the character does not occur.
indexOf
(int
a character (Unicode code point).
ch
,
int
the index to start the search from.
fromIndex
)

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

public int

Returns:

the index of the first occurrence of the character in the character sequence represented by this object that is greater than or equal to beginIndex and less than endIndex, or -1 if the character does not occur.
indexOf
(int
a character (Unicode code point).
ch
,
int
the index to start the search from (included).
beginIndex
,
int
the index to stop the search at (excluded).
endIndex
)

Returns the index within this string of the first occurrence of the specified character, starting the search at beginIndex and stopping before endIndex.

public int

Returns:

the index of the first occurrence of the specified substring, or -1 if there is no such occurrence.
indexOf
(String
the substring to search for.
str
)

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

public int

Returns:

the index of the first occurrence of the specified substring, starting at the specified index, or -1 if there is no such occurrence.
indexOf
(String
the substring to search for.
str
,
int
the index from which to start the search.
fromIndex
)

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

public int

Returns:

the index of the first occurrence of the specified substring within the specified index range, or -1 if there is no such occurrence.
indexOf
(String
the substring to search for.
str
,
int
the index to start the search from (included).
beginIndex
,
int
the index to stop the search at (excluded).
endIndex
)

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

pack-priv static int
indexOf(byte[]
the characters being searched.
src
,
byte
the coder of the source string.
srcCoder
,
int
last index (exclusive) in the source string.
srcCount
,
String
the characters being searched for.
tgtStr
,
int
the index to begin searching from.
fromIndex
)

Code shared by String and AbstractStringBuilder to do searches.

private int
public native String

Returns:

a string that has the same contents as this string, but is guaranteed to be from a pool of unique strings.
intern
()

Returns a canonical representation for the string object.

private static boolean
isASCII(byte[] src)

public boolean

Returns:

true if the string is empty or contains only white space codepoints, otherwise false
isBlank
()

Returns true if the string is empty or contains only white space codepoints, otherwise false.

public boolean

Returns:

true if length() is 0, otherwise false
isEmpty
()

Overrides default java.lang.CharSequence.isEmpty.

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

pack-priv boolean
private static boolean
isMalformed3(int b1, int b2, int b3)

private static boolean
isMalformed3_2(int b1, int b2)

private static boolean
isMalformed4(int b2, int b3, int b4)

private static boolean
isMalformed4_2(int b1, int b2)

private static boolean
private static boolean
public static String

Returns:

a new String that is composed of the elements separated by the delimiter
join
(CharSequence
the delimiter that separates each element
delimiter
,
CharSequence...
the elements to join together.
elements
)

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

pack-priv static String

Returns:

the joined string
join
(String
the non-null prefix
prefix
,
String
the non-null suffix
suffix
,
String
the non-null delimiter
delimiter
,
String[]
the non-null array of non-null elements
elements
,
int
the number of elements in the array (<= elements.length)
size
)

Designated join routine.

public static String

Returns:

a new String that is composed from the elements argument
join
(CharSequence
a sequence of characters that is used to separate each of the elements in the resulting String
delimiter
,
Iterable<? extends CharSequence>
an Iterable that will have its elements joined together.
elements
)

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

public int

Returns:

the index of the last occurrence of the character in the character sequence represented by this object, or -1 if the character does not occur.
lastIndexOf
(int
a character (Unicode code point).
ch
)

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

public int

Returns:

the index of the last occurrence of the character in the character sequence represented by this object that is less than or equal to fromIndex, or -1 if the character does not occur before that point.
lastIndexOf
(int
a character (Unicode code point).
ch
,
int
the index to start the search from. There is no restriction on the value of fromIndex. If it is greater than or equal to the length of this string, it has the same effect as if it were equal to one less than the length of this string: this entire string may be searched. If it is negative, it has the same effect as if it were -1: -1 is returned.
fromIndex
)

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

public int

Returns:

the index of the last occurrence of the specified substring, or -1 if there is no such occurrence.
lastIndexOf
(String
the substring to search for.
str
)

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

public int

Returns:

the index of the last occurrence of the specified substring, searching backward from the specified index, or -1 if there is no such occurrence.
lastIndexOf
(String
the substring to search for.
str
,
int
the index to start the search from.
fromIndex
)

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

pack-priv static int
lastIndexOf(byte[]
the characters being searched.
src
,
byte
coder handles the mapping between bytes/chars
srcCoder
,
int
count of the source string.
srcCount
,
String
the characters being searched for.
tgtStr
,
int
the index to begin searching from.
fromIndex
)

Code shared by String and AbstractStringBuilder to do searches.

private int
public int

Returns:

the length of the sequence of characters represented by this object.
length
()

Implements java.lang.CharSequence.length.

Returns the length of this string.

public Stream<String>

Returns:

the stream of lines extracted from this string
lines
()

Returns a stream of lines extracted from this string, separated by line terminators.

private static Charset
private static int
malformed3(byte[] src, int sp)

private static int
malformed4(byte[] src, int sp)

public boolean

Returns:

true if, and only if, this string matches the given regular expression
matches
(String
the regular expression to which this string is to be matched
regex
)

Tells whether or not this string matches the given regular expression.

pack-priv static String
newStringNoRepl(byte[] src, Charset cs)

private static String
newStringNoRepl1(byte[] src, Charset cs)

pack-priv static String
newStringUTF8NoRepl(byte[] bytes, int offset, int length, boolean noShare)

private boolean
public int

Returns:

the index within this String
offsetByCodePoints
(int
the index to be offset
index
,
int
the offset in code points
codePointOffset
)

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

private static int
private static Void
rangeCheck(char[] value, int offset, int count)

public boolean

Returns:

true if the specified subregion of this string exactly matches the specified subregion of the string argument; false otherwise.
regionMatches
(int
the starting offset of the subregion in this string.
toffset
,
String
the string argument.
other
,
int
the starting offset of the subregion in the string argument.
ooffset
,
int
the number of characters to compare.
len
)

Tests if two string regions are equal.

public boolean

Returns:

true if the specified subregion of this string matches the specified subregion of the string argument; false otherwise. Whether the matching is exact or case insensitive depends on the ignoreCase argument.
regionMatches
(boolean
if true, ignore case when comparing characters.
ignoreCase
,
int
the starting offset of the subregion in this string.
toffset
,
String
the string argument.
other
,
int
the starting offset of the subregion in the string argument.
ooffset
,
int
the number of characters (Unicode code units - 16bit char value) to compare.
len
)

Tests if two string regions are equal.

public String

Returns:

A string composed of this string repeated count times or the empty string if this string is empty or count is zero
repeat
(int
number of times to repeat
count
)

Returns a string whose value is the concatenation of this string repeated count times.

pack-priv static void
repeatCopyRest(byte[]
destination buffer
buffer
,
int
offset in the destination buffer
offset
,
int
total replicated including what is already in the buffer
limit
,
int
number of bytes that have already in the buffer
copied
)

Used to perform copying after the initial insertion.

public String

Returns:

a string derived from this string by replacing every occurrence of oldChar with newChar.
replace
(char
the old character.
oldChar
,
char
the new character.
newChar
)

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

public String

Returns:

The resulting string
replace
(CharSequence
The sequence of char values to be replaced
target
,
CharSequence
The replacement sequence of char values
replacement
)

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

public String

Returns:

The resulting String
replaceAll
(String
the regular expression to which this string is to be matched
regex
,
String
the string to be substituted for each match
replacement
)

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

public String

Returns:

The resulting String
replaceFirst
(String
the regular expression to which this string is to be matched
regex
,
String
the string to be substituted for the first match
replacement
)

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

private static void
replaceNegatives(byte[] val, int fromIndex)

public String

Returns:

the String instance
resolveConstantDesc
(MethodHandles.Lookup
ignored
lookup
)

Implements java.lang.constant.ConstantDesc.resolveConstantDesc.

Resolves this instance as a ConstantDesc, the result of which is the instance itself.

private static byte[]
safeTrim(byte[] ba, int len, boolean isTrusted)

private static int
scale(int len, float expansionFactor)

public String[]

Returns:

the array of strings computed by splitting this string around matches of the given regular expression
split
(String
the delimiting regular expression
regex
,
int
the result threshold, as described above
limit
)

Splits this string around matches of the given regular expression.

private String[]
split(String regex, int limit, boolean withDelimiters)

private String[]
split(char ch, int limit, boolean withDelimiters)

public String[]

Returns:

the array of strings computed by splitting this string around matches of the given regular expression
split
(String
the delimiting regular expression
regex
)

Splits this string around matches of the given regular expression.

public String[]

Returns:

the array of strings computed by splitting this string around matches of the given regular expression, alternating substrings and matching delimiters
splitWithDelimiters
(String
the delimiting regular expression
regex
,
int
the result threshold, as described above
limit
)

Splits this string around matches of the given regular expression and returns both the strings and the matching delimiters.

public boolean

Returns:

true if the character sequence represented by the argument is a prefix of the substring of this object starting at index toffset; false otherwise. The result is false if toffset is negative or greater than the length of this String object; otherwise the result is the same as the result of the expression
         this.substring(toffset).startsWith(prefix)
         
startsWith
(String
the prefix.
prefix
,
int
where to begin looking in this string.
toffset
)

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

public boolean

Returns:

true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise. Note also that true will be returned if the argument is an empty string or is equal to this String object as determined by the equals(Object) method.
startsWith
(String
the prefix.
prefix
)

Tests if this string starts with the specified prefix.

public String

Returns:

a string whose value is this string, with all leading and trailing white space removed
strip
()

Returns a string whose value is this string, with all leading and trailing white space removed.

public String

Returns:

string with incidental indentation removed and line terminators normalized
stripIndent
()

Returns a string whose value is this string, with incidental white space removed from the beginning and end of every line.

public String

Returns:

a string whose value is this string, with all leading white space removed
stripLeading
()

Returns a string whose value is this string, with all leading white space removed.

public String

Returns:

a string whose value is this string, with all trailing white space removed
stripTrailing
()

Returns a string whose value is this string, with all trailing white space removed.

public CharSequence

Returns:

the specified subsequence.
subSequence
(int
the begin index, inclusive.
beginIndex
,
int
the end index, exclusive.
endIndex
)

Implements java.lang.CharSequence.subSequence.

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

public String

Returns:

the specified substring.
substring
(int
the beginning index, inclusive.
beginIndex
)

Returns a string that is a substring of this string.

public String

Returns:

the specified substring.
substring
(int
the beginning index, inclusive.
beginIndex
,
int
the ending index, exclusive.
endIndex
)

Returns a string that is a substring of this string.

private static void
throwMalformed(int off, int nb)

private static void
throwMalformed(byte[] val)

private static void
throwUnmappable(int off)

private static void
throwUnmappable(byte[] val)

public char[]

Returns:

a newly allocated character array whose length is the length of this string and whose contents are initialized to contain the character sequence represented by this string.
toCharArray
()

Converts this string to a new character array.

public String

Returns:

the String, converted to lowercase.
toLowerCase
(Locale
use the case transformation rules for this locale
locale
)

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

public String

Returns:

the String, converted to lowercase.
toLowerCase
()

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

public String

Returns:

the string itself.
toString
()

Overrides java.lang.Object.toString.

Implements java.lang.CharSequence.toString.

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

public String

Returns:

the String, converted to uppercase.
toUpperCase
(Locale
use the case transformation rules for this locale
locale
)

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

public String

Returns:

the String, converted to uppercase.
toUpperCase
()

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

public <
the type of the result
R
>
R

Returns:

the result of applying the function to this string
transform
(Function<? super String, ? extends R>
a function to apply
f
)

This method allows the application of a function to this string.

public String

Returns:

String with escape sequences translated.
translateEscapes
()

Returns a string whose value is this string, with escape sequences translated as if in a string literal.

public String

Returns:

a string whose value is this string, with all leading and trailing space removed, or this string if it has no leading or trailing space.
trim
()

Returns a string whose value is this string, with all leading and trailing space removed, where space is defined as any character whose codepoint is less than or equal to 'U+0020' (the space character).

pack-priv byte[]
public static String

Returns:

if the argument is null, then a string equal to "null"; otherwise, the value of obj.toString() is returned.
valueOf
(Object
an Object.
obj
)

Returns the string representation of the Object argument.

public static String

Returns:

a String that contains the characters of the character array.
valueOf
(char[]
the character array.
data
)

Returns the string representation of the char array argument.

public static String

Returns:

a String that contains the characters of the specified subarray of the character array.
valueOf
(char[]
the character array.
data
,
int
initial offset of the subarray.
offset
,
int
length of the subarray.
count
)

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

public static String

Returns:

if the argument is true, a string equal to "true" is returned; otherwise, a string equal to "false" is returned.
valueOf
(boolean
a boolean.
b
)

Returns the string representation of the boolean argument.

public static String

Returns:

a string of length 1 containing as its single character the argument c.
valueOf
(char
a char.
c
)

Returns the string representation of the char argument.

public static String

Returns:

a string representation of the int argument.
valueOf
(int
an int.
i
)

Returns the string representation of the int argument.

public static String

Returns:

a string representation of the long argument.
valueOf
(long
a long.
l
)

Returns the string representation of the long argument.

public static String

Returns:

a string representation of the float argument.
valueOf
(float
a float.
f
)

Returns the string representation of the float argument.

public static String

Returns:

a string representation of the double argument.
valueOf
(double
a double.
d
)

Returns the string representation of the double argument.

pack-priv static String

Returns:

a string of length 1 or 2 containing as its single character the argument codePoint.
valueOfCodePoint
(int
a codePoint.
codePoint
)

Returns the string representation of the codePoint argument.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait