Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.lang
Class String  view String download String.java

java.lang.Object
  extended byjava.lang.String
All Implemented Interfaces:
CharSequence, Comparable, java.io.Serializable

public final class String
extends Object
implements java.io.Serializable, Comparable, CharSequence

Strings represent an immutable set of characters. All String literals are instances of this class, and two string literals with the same contents refer to the same String object.

This class also includes a number of methods for manipulating the contents of strings (of course, creating a new object if there are any changes, as String is immutable). Case mapping relies on Unicode 3.0.0 standards, where some character sequences have a different number of characters in the uppercase version than the lower case.

Strings are special, in that they are the only object with an overloaded operator. When you use '+' with at least one String argument, both arguments have String conversion performed on them, and another String (not guaranteed to be unique) results.

String is special-cased when doing data serialization - rather than listing the fields of this class, a String object is converted to a string literal in the object stream.

Since:
1.0

Nested Class Summary
private static class String.CaseInsensitiveComparator
          An implementation for CASE_INSENSITIVE_ORDER 55 .
 
Field Summary
private  int cachedHashCode
          Caches the result of hashCode().
static java.util.Comparator CASE_INSENSITIVE_ORDER
          A Comparator that uses String.compareToIgnoreCase(String).
(package private)  int count
          Holds the number of characters in value.
(package private)  int offset
          Holds the starting position for characters in value[].
private static long serialVersionUID
          This is probably not necessary because this class is special cased already but it will avoid showing up as a discrepancy when comparing SUIDs.
private static char[] upperExpand
          Stores unicode multi-character uppercase expansion table.
private static char[] upperSpecial
          Stores unicode multi-character uppercase special casing table.
(package private)  char[] value
          Characters which make up the String.
 
Constructor Summary
  String()
          Creates an empty String (length 0).
  String(byte[] data)
          Creates a new String using the byte array.
  String(byte[] ascii, int hibyte)
          Deprecated. use String(byte[], String) 55 to perform correct encoding
  String(byte[] data, int offset, int count)
          Creates a new String using the portion of the byte array starting at the offset and ending at offset + count.
  String(byte[] ascii, int hibyte, int offset, int count)
          Deprecated. use String(byte[], int, int, String) 55 to perform correct encoding
  String(byte[] data, int offset, int count, String encoding)
          Creates a new String using the portion of the byte array starting at the offset and ending at offset + count.
  String(byte[] data, String encoding)
          Creates a new String using the byte array.
  String(char[] data)
          Creates a new String using the character sequence of the char array.
  String(char[] data, int offset, int count)
          Creates a new String using the character sequence of a subarray of characters.
(package private) String(char[] data, int offset, int count, boolean dont_copy)
          Special constructor which can share an array when safe to do so.
  String(int[] codePoints, int offset, int count)
          Creates a new String containing the characters represented in the given subarray of Unicode code points.
  String(String str)
          Copies the contents of a String to a new String.
  String(StringBuffer buffer)
          Creates a new String using the character sequence represented by the StringBuffer.
  String(StringBuilder buffer)
          Creates a new String using the character sequence represented by the StringBuilder.
 
Method Summary
 char charAt(int index)
          Returns the character located at the specified index within this String.
 int codePointAt(int index)
          Get the code point at the specified index.
 int codePointBefore(int index)
          Get the code point before the specified index.
 int codePointCount(int start, int end)
          Return the number of code points between two indices in the String.
 int compareTo(Object o)
          Behaves like compareTo(java.lang.String) unless the Object is not a String.
 int compareTo(String anotherString)
          Compares this String and another String (case sensitive, lexicographically).
 int compareToIgnoreCase(String str)
          Compares this String and another String (case insensitive).
 String concat(String str)
          Concatenates a String to this String.
 boolean contains(CharSequence s)
          Returns true iff this String contains the sequence of Characters described in s.
 boolean contentEquals(CharSequence seq)
          Compares the given CharSequence to this String.
 boolean contentEquals(StringBuffer buffer)
          Compares the given StringBuffer to this String.
static String copyValueOf(char[] data)
          Returns a String representation of a character array.
static String copyValueOf(char[] data, int offset, int count)
          Returns a String representing the character sequence of the char array, starting at the specified offset, and copying chars up to the specified count.
 boolean endsWith(String suffix)
          Predicate which determines if this String ends with a given suffix.
 boolean equals(Object anObject)
          Predicate which compares anObject to this.
 boolean equalsIgnoreCase(String anotherString)
          Compares a String to this String, ignoring case.
 byte[] getBytes()
          Converts the Unicode characters in this String to a byte array.
 void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)
          Deprecated. use getBytes() 55 , which uses a char to byte encoder
 byte[] getBytes(String enc)
          Converts the Unicode characters in this String to a byte array.
 void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
          Copies characters from this String starting at a specified start index, ending at a specified stop index, to a character array starting at a specified destination begin index.
 int hashCode()
          Computes the hashcode for this String.
 int indexOf(int ch)
          Finds the first instance of a character in this String.
 int indexOf(int ch, int fromIndex)
          Finds the first instance of a character in this String, starting at a given index.
 int indexOf(String str)
          Finds the first instance of a String in this String.
 int indexOf(String str, int fromIndex)
          Finds the first instance of a String in this String, starting at a given index.
 String intern()
          If two Strings are considered equal, by the equals() method, then intern() will return the same String instance.
 int lastIndexOf(int ch)
          Finds the last instance of a character in this String.
 int lastIndexOf(int ch, int fromIndex)
          Finds the last instance of a character in this String, starting at a given index.
 int lastIndexOf(String str)
          Finds the last instance of a String in this String.
 int lastIndexOf(String str, int fromIndex)
          Finds the last instance of a String in this String, starting at a given index.
 int length()
          Returns the number of characters contained in this String.
 boolean matches(String regex)
          Test if this String matches a regular expression.
 int offsetByCodePoints(int index, int codePointOffset)
          Return the index into this String that is offset from the given index by codePointOffset code points.
 boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)
          Predicate which determines if this String matches another String starting at a specified offset for each String and continuing for a specified length, optionally ignoring case.
 boolean regionMatches(int toffset, String other, int ooffset, int len)
          Predicate which determines if this String matches another String starting at a specified offset for each String and continuing for a specified length.
 String replace(char oldChar, char newChar)
          Replaces every instance of a character in this String with a new character.
 String replace(CharSequence target, CharSequence replacement)
          Returns a string that is this string with all instances of the sequence represented by target replaced by the sequence in replacement.
 String replaceAll(String regex, String replacement)
          Replaces all matching substrings of the regular expression with a given replacement.
 String replaceFirst(String regex, String replacement)
          Replaces the first substring match of the regular expression with a given replacement.
 String[] split(String regex)
          Split this string around the matches of a regular expression.
 String[] split(String regex, int limit)
          Split this string around the matches of a regular expression.
 boolean startsWith(String prefix)
          Predicate which determines if this String starts with a given prefix.
 boolean startsWith(String prefix, int toffset)
          Predicate which determines if this String contains the given prefix, beginning comparison at toffset.
 CharSequence subSequence(int begin, int end)
          Creates a substring of this String, starting at a specified index and ending at one character before a specified index.
 String substring(int begin)
          Creates a substring of this String, starting at a specified index and ending at the end of this String.
 String substring(int beginIndex, int endIndex)
          Creates a substring of this String, starting at a specified index and ending at one character before a specified index.
 char[] toCharArray()
          Copies the contents of this String into a character array.
 String toLowerCase()
          Lowercases this String.
 String toLowerCase(java.util.Locale loc)
          Lowercases this String according to a particular locale.
 String toString()
          Returns this, as it is already a String!
 String toUpperCase()
          Uppercases this String.
 String toUpperCase(java.util.Locale loc)
          Uppercases this String according to a particular locale.
 String trim()
          Trims all characters less than or equal to ' ' (' ') from the beginning and end of this String.
private static int upperCaseExpansion(char ch)
          Helper function used to detect which characters have a multi-character uppercase expansion.
private static int upperCaseIndex(char ch)
          Helper function used to locate the offset in upperExpand given a character with a multi-character expansion.
static String valueOf(boolean b)
          Returns a String representing a boolean.
static String valueOf(char c)
          Returns a String representing a character.
static String valueOf(char[] data)
          Returns a String representation of a character array.
static String valueOf(char[] data, int offset, int count)
          Returns a String representing the character sequence of the char array, starting at the specified offset, and copying chars up to the specified count.
static String valueOf(double d)
          Returns a String representing a double.
static String valueOf(float f)
          Returns a String representing a float.
static String valueOf(int i)
          Returns a String representing an integer.
static String valueOf(long l)
          Returns a String representing a long.
static String valueOf(Object obj)
          Returns a String representation of an Object.
(package private) static char[] zeroBasedStringValue(String s)
          Returns the value array of the given string if it is zero based or a copy of it that is zero based (stripping offset and making length equal to count).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This is probably not necessary because this class is special cased already but it will avoid showing up as a discrepancy when comparing SUIDs.

See Also:
Constant Field Values

upperExpand

private static final char[] upperExpand
Stores unicode multi-character uppercase expansion table.

See Also:
toUpperCase(Locale) 55 , CharData.UPPER_EXPAND>CharData.UPPER_EXPAND 55

upperSpecial

private static final char[] upperSpecial
Stores unicode multi-character uppercase special casing table.

See Also:
upperCaseExpansion(char) 55 , CharData.UPPER_SPECIAL>CharData.UPPER_SPECIAL 55

value

final char[] value
Characters which make up the String. Package access is granted for use by StringBuffer.


count

final int count
Holds the number of characters in value. This number is generally the same as value.length, but can be smaller because substrings and StringBuffers can share arrays. Package visible for use by trusted code.


cachedHashCode

private int cachedHashCode
Caches the result of hashCode(). If this value is zero, the hashcode is considered uncached (even if 0 is the correct hash value).


offset

final int offset
Holds the starting position for characters in value[]. Since substring()'s are common, the use of offset allows the operation to perform in O(1). Package access is granted for use by StringBuffer.


CASE_INSENSITIVE_ORDER

public static final java.util.Comparator CASE_INSENSITIVE_ORDER
A Comparator that uses String.compareToIgnoreCase(String). This comparator is java.io.Serializable. Note that it ignores Locale, for that, you want a Collator.

Since:
1.2
See Also:
Collator.compare(String, String)>Collator.compare(String, String) 55
Constructor Detail

String

public String()
Creates an empty String (length 0). Unless you really need a new object, consider using "" instead.


String

public String(String str)
Copies the contents of a String to a new String. Since Strings are immutable, only a shallow copy is performed.


String

public String(char[] data)
Creates a new String using the character sequence of the char array. Subsequent changes to data do not affect the String.


String

public String(char[] data,
              int offset,
              int count)
Creates a new String using the character sequence of a subarray of characters. The string starts at offset, and copies count chars. Subsequent changes to data do not affect the String.


String

public String(byte[] ascii,
              int hibyte,
              int offset,
              int count)
Deprecated. use String(byte[], int, int, String) 55 to perform correct encoding

Creates a new String using an 8-bit array of integer values, starting at an offset, and copying up to the count. Each character c, using corresponding byte b, is created in the new String as if by performing:
 c = (char) (((hibyte & 0xff) << 8) | (b & 0xff))
 


String

public String(byte[] ascii,
              int hibyte)
Deprecated. use String(byte[], String) 55 to perform correct encoding

Creates a new String using an 8-bit array of integer values. Each character c, using corresponding byte b, is created in the new String as if by performing:
 c = (char) (((hibyte & 0xff) << 8) | (b & 0xff))
 


String

public String(byte[] data,
              int offset,
              int count,
              String encoding)
       throws java.io.UnsupportedEncodingException
Creates a new String using the portion of the byte array starting at the offset and ending at offset + count. Uses the specified encoding type to decode the byte array, so the resulting string may be longer or shorter than the byte array. For more decoding control, use java.nio.charset.CharsetDecoder, and for valid character sets, see java.nio.charset.Charset. The behavior is not specified if the decoder encounters invalid characters; this implementation throws an Error.

Since:
1.1

String

public String(byte[] data,
              String encoding)
       throws java.io.UnsupportedEncodingException
Creates a new String using the byte array. Uses the specified encoding type to decode the byte array, so the resulting string may be longer or shorter than the byte array. For more decoding control, use java.nio.charset.CharsetDecoder, and for valid character sets, see java.nio.charset.Charset. The behavior is not specified if the decoder encounters invalid characters; this implementation throws an Error.

Since:
1.1

String

public String(byte[] data,
              int offset,
              int count)
Creates a new String using the portion of the byte array starting at the offset and ending at offset + count. Uses the encoding of the platform's default charset, so the resulting string may be longer or shorter than the byte array. For more decoding control, use java.nio.charset.CharsetDecoder. The behavior is not specified if the decoder encounters invalid characters; this implementation throws an Error.

Since:
1.1

String

public String(byte[] data)
Creates a new String using the byte array. Uses the encoding of the platform's default charset, so the resulting string may be longer or shorter than the byte array. For more decoding control, use java.nio.charset.CharsetDecoder. The behavior is not specified if the decoder encounters invalid characters; this implementation throws an Error.

Since:
1.1

String

public String(StringBuffer buffer)
Creates a new String using the character sequence represented by the StringBuffer. Subsequent changes to buf do not affect the String.


String

public String(StringBuilder buffer)
Creates a new String using the character sequence represented by the StringBuilder. Subsequent changes to buf do not affect the String.


String

String(char[] data,
       int offset,
       int count,
       boolean dont_copy)
Special constructor which can share an array when safe to do so.


String

public String(int[] codePoints,
              int offset,
              int count)
Creates a new String containing the characters represented in the given subarray of Unicode code points.

Method Detail

length

public int length()
Returns the number of characters contained in this String.

Specified by:
length in interface CharSequence

charAt

public char charAt(int index)
Returns the character located at the specified index within this String.

Specified by:
charAt in interface CharSequence

codePointAt

public int codePointAt(int index)
Get the code point at the specified index. This is like #charAt(int), but if the character is the start of a surrogate pair, and the following character completes the pair, then the corresponding supplementary code point is returned.

Since:
1.5

codePointBefore

public int codePointBefore(int index)
Get the code point before the specified index. This is like #codePointAt(int), but checks the characters at index-1 and index-2 to see if they form a supplementary code point.

Since:
1.5

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)
Copies characters from this String starting at a specified start index, ending at a specified stop index, to a character array starting at a specified destination begin index.


getBytes

public void getBytes(int srcBegin,
                     int srcEnd,
                     byte[] dst,
                     int dstBegin)
Deprecated. use getBytes() 55 , which uses a char to byte encoder

Copies the low byte of each character from this String starting at a specified start index, ending at a specified stop index, to a byte array starting at a specified destination begin index.


getBytes

public byte[] getBytes(String enc)
                throws java.io.UnsupportedEncodingException
Converts the Unicode characters in this String to a byte array. Uses the specified encoding method, so the result may be longer or shorter than the String. For more encoding control, use java.nio.charset.CharsetEncoder, and for valid character sets, see java.nio.charset.Charset. Unsupported characters get replaced by an encoding specific byte.

Since:
1.1

getBytes

public byte[] getBytes()
Converts the Unicode characters in this String to a byte array. Uses the encoding of the platform's default charset, so the result may be longer or shorter than the String. For more encoding control, use java.nio.charset.CharsetEncoder. Unsupported characters get replaced by an encoding specific byte.

Since:
1.1

equals

public boolean equals(Object anObject)
Predicate which compares anObject to this. This is true only for Strings with the same character sequence.

Overrides:
equals in class Object

contentEquals

public boolean contentEquals(StringBuffer buffer)
Compares the given StringBuffer to this String. This is true if the StringBuffer has the same content as this String at this moment.

Since:
1.4

contentEquals

public boolean contentEquals(CharSequence seq)
Compares the given CharSequence to this String. This is true if the CharSequence has the same content as this String at this moment.

Since:
1.5

equalsIgnoreCase

public boolean equalsIgnoreCase(String anotherString)
Compares a String to this String, ignoring case. This does not handle multi-character capitalization exceptions; instead the comparison is made on a character-by-character basis, and is true if:
  • c1 == c2
  • Character.toUpperCase(c1) == Character.toUpperCase(c2)
  • Character.toLowerCase(c1) == Character.toLowerCase(c2)


compareTo

public int compareTo(String anotherString)
Compares this String and another String (case sensitive, lexicographically). The result is less than 0 if this string sorts before the other, 0 if they are equal, and greater than 0 otherwise. After any common starting sequence is skipped, the result is this.charAt(k) - anotherString.charAt(k) if both strings have characters remaining, or this.length() - anotherString.length() if one string is a subsequence of the other.


compareTo

public int compareTo(Object o)
Behaves like compareTo(java.lang.String) unless the Object is not a String. Then it throws a ClassCastException.

Specified by:
compareTo in interface Comparable
Since:
1.2

compareToIgnoreCase

public int compareToIgnoreCase(String str)
Compares this String and another String (case insensitive). This comparison is similar to equalsIgnoreCase, in that it ignores locale and multi-characater capitalization, and compares characters after performing Character.toLowerCase(Character.toUpperCase(c)) on each character of the string. This is unsatisfactory for locale-based comparison, in which case you should use java.text.Collator.

Since:
1.2

regionMatches

public boolean regionMatches(int toffset,
                             String other,
                             int ooffset,
                             int len)
Predicate which determines if this String matches another String starting at a specified offset for each String and continuing for a specified length. Indices out of bounds are harmless, and give a false result.


regionMatches

public boolean regionMatches(boolean ignoreCase,
                             int toffset,
                             String other,
                             int ooffset,
                             int len)
Predicate which determines if this String matches another String starting at a specified offset for each String and continuing for a specified length, optionally ignoring case. Indices out of bounds are harmless, and give a false result. Case comparisons are based on Character.toLowerCase() and Character.toUpperCase(), not on multi-character capitalization expansions.


startsWith

public boolean startsWith(String prefix,
                          int toffset)
Predicate which determines if this String contains the given prefix, beginning comparison at toffset. The result is false if toffset is negative or greater than this.length(), otherwise it is the same as this.substring(toffset).startsWith(prefix).


startsWith

public boolean startsWith(String prefix)
Predicate which determines if this String starts with a given prefix. If the prefix is an empty String, true is returned.


endsWith

public boolean endsWith(String suffix)
Predicate which determines if this String ends with a given suffix. If the suffix is an empty String, true is returned.


hashCode

public int hashCode()
Computes the hashcode for this String. This is done with int arithmetic, where ** represents exponentiation, by this formula:
s[0]*31**(n-1) + s[1]*31**(n-2) + ... + s[n-1].

Overrides:
hashCode in class Object

indexOf

public int indexOf(int ch)
Finds the first instance of a character in this String.


indexOf

public int indexOf(int ch,
                   int fromIndex)
Finds the first instance of a character in this String, starting at a given index. If starting index is less than 0, the search starts at the beginning of this String. If the starting index is greater than the length of this String, -1 is returned.


lastIndexOf

public int lastIndexOf(int ch)
Finds the last instance of a character in this String.


lastIndexOf

public int lastIndexOf(int ch,
                       int fromIndex)
Finds the last instance of a character in this String, starting at a given index. If starting index is greater than the maximum valid index, then the search begins at the end of this String. If the starting index is less than zero, -1 is returned.


indexOf

public int indexOf(String str)
Finds the first instance of a String in this String.


indexOf

public int indexOf(String str,
                   int fromIndex)
Finds the first instance of a String in this String, starting at a given index. If starting index is less than 0, the search starts at the beginning of this String. If the starting index is greater than the length of this String, -1 is returned.


lastIndexOf

public int lastIndexOf(String str)
Finds the last instance of a String in this String.


lastIndexOf

public int lastIndexOf(String str,
                       int fromIndex)
Finds the last instance of a String in this String, starting at a given index. If starting index is greater than the maximum valid index, then the search begins at the end of this String. If the starting index is less than zero, -1 is returned.


substring

public String substring(int begin)
Creates a substring of this String, starting at a specified index and ending at the end of this String.


substring

public String substring(int beginIndex,
                        int endIndex)
Creates a substring of this String, starting at a specified index and ending at one character before a specified index.


subSequence

public CharSequence subSequence(int begin,
                                int end)
Creates a substring of this String, starting at a specified index and ending at one character before a specified index. This behaves like substring(begin, end).

Specified by:
subSequence in interface CharSequence
Since:
1.4

concat

public String concat(String str)
Concatenates a String to this String. This results in a new string unless one of the two originals is "".


replace

public String replace(char oldChar,
                      char newChar)
Replaces every instance of a character in this String with a new character. If no replacements occur, this is returned.


matches

public boolean matches(String regex)
Test if this String matches a regular expression. This is shorthand for java.util.regex.Pattern.matches(regex, this).

Since:
1.4

replaceFirst

public String replaceFirst(String regex,
                           String replacement)
Replaces the first substring match of the regular expression with a given replacement. This is shorthand for java.util.regex.Pattern .compile(regex).matcher(this).replaceFirst(replacement).

Since:
1.4

replaceAll

public String replaceAll(String regex,
                         String replacement)
Replaces all matching substrings of the regular expression with a given replacement. This is shorthand for java.util.regex.Pattern .compile(regex).matcher(this).replaceAll(replacement).

Since:
1.4

split

public String[] split(String regex,
                      int limit)
Split this string around the matches of a regular expression. Each element of the returned array is the largest block of characters not terminated by the regular expression, in the order the matches are found.

The limit affects the length of the array. If it is positive, the array will contain at most n elements (n - 1 pattern matches). If negative, the array length is unlimited, but there can be trailing empty entries. if 0, the array length is unlimited, and trailing empty entries are discarded.

For example, splitting "boo:and:foo" yields:
Regex Limit Result
":" 2 { "boo", "and:foo" }
":" t { "boo", "and", "foo" }
":" -2 { "boo", "and", "foo" }
"o" 5 { "b", "", ":and:f", "", "" }
"o" -2 { "b", "", ":and:f", "", "" }
"o" 0 { "b", "", ":and:f" }

This is shorthand for java.util.regex.Pattern.compile(regex).split(this, limit).

Since:
1.4

split

public String[] split(String regex)
Split this string around the matches of a regular expression. Each element of the returned array is the largest block of characters not terminated by the regular expression, in the order the matches are found. The array length is unlimited, and trailing empty entries are discarded, as though calling split(regex, 0).

Since:
1.4

toLowerCase

public String toLowerCase(java.util.Locale loc)
Lowercases this String according to a particular locale. This uses Unicode's special case mappings, as applied to the given Locale, so the resulting string may be a different length.

Since:
1.1

toLowerCase

public String toLowerCase()
Lowercases this String. This uses Unicode's special case mappings, as applied to the platform's default Locale, so the resulting string may be a different length.


toUpperCase

public String toUpperCase(java.util.Locale loc)
Uppercases this String according to a particular locale. This uses Unicode's special case mappings, as applied to the given Locale, so the resulting string may be a different length.

Since:
1.1

toUpperCase

public String toUpperCase()
Uppercases this String. This uses Unicode's special case mappings, as applied to the platform's default Locale, so the resulting string may be a different length.


trim

public String trim()
Trims all characters less than or equal to ' ' (' ') from the beginning and end of this String. This includes many, but not all, ASCII control characters, and all Character.isWhitespace(char) 55 .


toString

public String toString()
Returns this, as it is already a String!

Specified by:
toString in interface CharSequence
Overrides:
toString in class Object

toCharArray

public char[] toCharArray()
Copies the contents of this String into a character array. Subsequent changes to the array do not affect the String.


valueOf

public static String valueOf(Object obj)
Returns a String representation of an Object. This is "null" if the object is null, otherwise it is obj.toString() (which can be null).


valueOf

public static String valueOf(char[] data)
Returns a String representation of a character array. Subsequent changes to the array do not affect the String.


valueOf

public static String valueOf(char[] data,
                             int offset,
                             int count)
Returns a String representing the character sequence of the char array, starting at the specified offset, and copying chars up to the specified count. Subsequent changes to the array do not affect the String.


copyValueOf

public static String copyValueOf(char[] data,
                                 int offset,
                                 int count)
Returns a String representing the character sequence of the char array, starting at the specified offset, and copying chars up to the specified count. Subsequent changes to the array do not affect the String.


copyValueOf

public static String copyValueOf(char[] data)
Returns a String representation of a character array. Subsequent changes to the array do not affect the String.


valueOf

public static String valueOf(boolean b)
Returns a String representing a boolean.


valueOf

public static String valueOf(char c)
Returns a String representing a character.


valueOf

public static String valueOf(int i)
Returns a String representing an integer.


valueOf

public static String valueOf(long l)
Returns a String representing a long.


valueOf

public static String valueOf(float f)
Returns a String representing a float.


valueOf

public static String valueOf(double d)
Returns a String representing a double.


intern

public String intern()
If two Strings are considered equal, by the equals() method, then intern() will return the same String instance. ie. if (s1.equals(s2)) then (s1.intern() == s2.intern()). All string literals and string-valued constant expressions are already interned.


codePointCount

public int codePointCount(int start,
                          int end)
Return the number of code points between two indices in the String. An unpaired surrogate counts as a code point for this purpose. Characters outside the indicated range are not examined, even if the range ends in the middle of a surrogate pair.

Since:
1.5

upperCaseExpansion

private static int upperCaseExpansion(char ch)
Helper function used to detect which characters have a multi-character uppercase expansion. Note that this is only used in locations which track one-to-many capitalization (java.lang.Character does not do this). As of Unicode 3.0.0, the result is limited in the range 0 to 2, as the longest uppercase expansion is three characters (a growth of 2 from the lowercase character).


upperCaseIndex

private static int upperCaseIndex(char ch)
Helper function used to locate the offset in upperExpand given a character with a multi-character expansion. The binary search is optimized under the assumption that this method will only be called on characters which exist in upperSpecial.


zeroBasedStringValue

static char[] zeroBasedStringValue(String s)
Returns the value array of the given string if it is zero based or a copy of it that is zero based (stripping offset and making length equal to count). Used for accessing the char[]s of gnu.java.lang.CharData. Package private for use in Character.


contains

public boolean contains(CharSequence s)
Returns true iff this String contains the sequence of Characters described in s.

Since:
1.5

replace

public String replace(CharSequence target,
                      CharSequence replacement)
Returns a string that is this string with all instances of the sequence represented by target replaced by the sequence in replacement.


offsetByCodePoints

public int offsetByCodePoints(int index,
                              int codePointOffset)
Return the index into this String that is offset from the given index by codePointOffset code points.

Since:
1.5