1 *java.lang.String* *String* The String class represents character strings.
3 public final class String
4 extends |java.lang.Object|
5 implements |java.io.Serializable|
7 |java.lang.CharSequence|
9 |java.lang.String_Description|
10 |java.lang.String_Fields|
11 |java.lang.String_Constructors|
12 |java.lang.String_Methods|
14 ================================================================================
16 *java.lang.String_Fields*
17 |java.util.Comparator<java.lang.String>_java.lang.String.CASE_INSENSITIVE_ORDER|
19 *java.lang.String_Constructors*
20 |java.lang.String()|Initializes a newly createdStringobject so that it represen
21 |java.lang.String(byte[])|Constructs a newStringby decoding the specified array
22 |java.lang.String(byte[],Charset)|Constructs a newStringby decoding the specifi
23 |java.lang.String(byte[],int)|Allocates a newStringcontaining characters constr
24 |java.lang.String(byte[],int,int)|Constructs a newStringby decoding the specifi
25 |java.lang.String(byte[],int,int,Charset)|Constructs a newStringby decoding the
26 |java.lang.String(byte[],int,int,int)|Allocates a newStringconstructed from a s
27 |java.lang.String(byte[],int,int,String)|Constructs a newStringby decoding the
28 |java.lang.String(byte[],String)|Constructs a newStringby decoding the specifie
29 |java.lang.String(char[])|Allocates a newStringso that it represents the sequen
30 |java.lang.String(char[],int,int)|Allocates a newStringthat contains characters
31 |java.lang.String(int[],int,int)|Allocates a newStringthat contains characters
32 |java.lang.String(String)|Initializes a newly createdStringobject so that it re
33 |java.lang.String(StringBuffer)|Allocates a new string that contains the sequen
34 |java.lang.String(StringBuilder)|Allocates a new string that contains the seque
36 *java.lang.String_Methods*
37 |java.lang.String.charAt(int)|Returns the char value at the specified index.
38 |java.lang.String.codePointAt(int)|Returns the character (Unicode code point) a
39 |java.lang.String.codePointBefore(int)|Returns the character (Unicode code poin
40 |java.lang.String.codePointCount(int,int)|Returns the number of Unicode code po
41 |java.lang.String.compareTo(String)|Compares two strings lexicographically.
42 |java.lang.String.compareToIgnoreCase(String)|Compares two strings lexicographi
43 |java.lang.String.concat(String)|Concatenates the specified string to the end o
44 |java.lang.String.contains(CharSequence)|Returns true if and only if this strin
45 |java.lang.String.contentEquals(CharSequence)|Compares this string to the speci
46 |java.lang.String.contentEquals(StringBuffer)|Compares this string to the speci
47 |java.lang.String.copyValueOf(char[])|Returns a String that represents the char
48 |java.lang.String.copyValueOf(char[],int,int)|Returns a String that represents
49 |java.lang.String.endsWith(String)|Tests if this string ends with the specified
50 |java.lang.String.equals(Object)|Compares this string to the specified object.
51 |java.lang.String.equalsIgnoreCase(String)|Compares thisStringto anotherString,
52 |java.lang.String.format(Locale,String,Object...)|Returns a formatted string us
53 |java.lang.String.format(String,Object...)|Returns a formatted string using the
54 |java.lang.String.getBytes()|Encodes thisStringinto a sequence of bytes using t
55 |java.lang.String.getBytes(Charset)|Encodes thisStringinto a sequence of bytes
56 |java.lang.String.getBytes(int,int,byte[],int)|Copies characters from this stri
57 |java.lang.String.getBytes(String)|Encodes thisStringinto a sequence of bytes u
58 |java.lang.String.getChars(int,int,char[],int)|Copies characters from this stri
59 |java.lang.String.hashCode()|Returns a hash code for this string.
60 |java.lang.String.indexOf(int)|Returns the index within this string of the firs
61 |java.lang.String.indexOf(int,int)|Returns the index within this string of the
62 |java.lang.String.indexOf(String)|Returns the index within this string of the f
63 |java.lang.String.indexOf(String,int)|Returns the index within this string of t
64 |java.lang.String.intern()|Returns a canonical representation for the string ob
65 |java.lang.String.isEmpty()|Returns true if, and only if,#length()is 0.
66 |java.lang.String.lastIndexOf(int)|Returns the index within this string of the
67 |java.lang.String.lastIndexOf(int,int)|Returns the index within this string of
68 |java.lang.String.lastIndexOf(String)|Returns the index within this string of t
69 |java.lang.String.lastIndexOf(String,int)|Returns the index within this string
70 |java.lang.String.length()|Returns the length of this string.
71 |java.lang.String.matches(String)|Tells whether or not this string matches the
72 |java.lang.String.offsetByCodePoints(int,int)|Returns the index within this Str
73 |java.lang.String.regionMatches(boolean,int,String,int,int)|Tests if two string
74 |java.lang.String.regionMatches(int,String,int,int)|Tests if two string regions
75 |java.lang.String.replace(char,char)|Returns a new string resulting from replac
76 |java.lang.String.replace(CharSequence,CharSequence)|Replaces each substring of
77 |java.lang.String.replaceAll(String,String)|Replaces each substring of this str
78 |java.lang.String.replaceFirst(String,String)|Replaces the first substring of t
79 |java.lang.String.split(String)|Splits this string around matches of the given
80 |java.lang.String.split(String,int)|Splits this string around matches of the gi
81 |java.lang.String.startsWith(String)|Tests if this string starts with the speci
82 |java.lang.String.startsWith(String,int)|Tests if the substring of this string
83 |java.lang.String.subSequence(int,int)|Returns a new character sequence that is
84 |java.lang.String.substring(int)|Returns a new string that is a substring of th
85 |java.lang.String.substring(int,int)|Returns a new string that is a substring o
86 |java.lang.String.toCharArray()|Converts this string to a new character array.
87 |java.lang.String.toLowerCase()|Converts all of the characters in this String t
88 |java.lang.String.toLowerCase(Locale)|Converts all of the characters in this St
89 |java.lang.String.toString()|This object (which is already a string!) is itself
90 |java.lang.String.toUpperCase()|Converts all of the characters in this String t
91 |java.lang.String.toUpperCase(Locale)|Converts all of the characters in this St
92 |java.lang.String.trim()|Returns a copy of the string, with leading and trailin
93 |java.lang.String.valueOf(boolean)|Returns the string representation of the boo
94 |java.lang.String.valueOf(char)|Returns the string representation of the char
95 |java.lang.String.valueOf(char[])|Returns the string representation of the char
96 |java.lang.String.valueOf(char[],int,int)|Returns the string representation of
97 |java.lang.String.valueOf(double)|Returns the string representation of the doub
98 |java.lang.String.valueOf(float)|Returns the string representation of the float
99 |java.lang.String.valueOf(int)|Returns the string representation of the int arg
100 |java.lang.String.valueOf(long)|Returns the string representation of the long a
101 |java.lang.String.valueOf(Object)|Returns the string representation of the Obje
103 *java.lang.String_Description*
105 The String class represents character strings. All string literals in Java
106 programs, such as "abc", are implemented as instances of this class.
108 Strings are constant; their values cannot be changed after they are created.
109 String buffers support mutable strings. Because String objects are immutable
110 they can be shared. For example:
116 char data[] = {'a', 'b', 'c'}; String str = new String(data);
118 Here are some more examples of how strings can be used:
120 System.out.println("abc"); String cde = "cde"; System.out.println("abc" + cde);
121 String c = "abc".substring(2,3); String d = cde.substring(1, 2);
123 The class String includes methods for examining individual characters of the
124 sequence, for comparing strings, for searching strings, for extracting
125 substrings, and for creating a copy of a string with all characters translated
126 to uppercase or to lowercase. Case mapping is based on the Unicode Standard
127 version specified by the Character(|java.lang.Character|) class.
129 The Java language provides special support for the string concatenation
130 operator (+), and for conversion of other objects to strings. String
131 concatenation is implemented through the StringBuilder(or StringBuffer) class
132 and its append method. String conversions are implemented through the method
133 toString, defined by Object and inherited by all classes in Java. For
134 additional information on string concatenation and conversion, see Gosling,
135 Joy, and Steele, The Java Language Specification.
137 Unless otherwise noted, passing a null argument to a constructor or method in
138 this class will cause a (|java.lang.NullPointerException|) to be thrown.
140 A String represents a string in the UTF-16 format in which supplementary
141 characters are represented by surrogate pairs (see the section Unicode
142 Character Representations in the Character class for more information). Index
143 values refer to char code units, so a supplementary character uses two
144 positions in a String. The String class provides methods for dealing with
145 Unicode code points (i.e., characters), in addition to those for dealing with
146 Unicode code units (i.e., char values).
150 *java.util.Comparator<java.lang.String>_java.lang.String.CASE_INSENSITIVE_ORDER*
152 A Comparator that orders String objects as by compareToIgnoreCase. This
153 comparator is serializable.
155 Note that this Comparator does not take locale into account, and will result in
156 an unsatisfactory ordering for certain locales. The java.text package provides
157 Collators to allow locale-sensitive ordering.
165 Initializes a newly createdStringobject so that it represents an empty
166 character sequence. Note that use of this constructor is unnecessary since
167 Strings are immutable.
170 *java.lang.String(byte[])*
172 public String(byte[] bytes)
174 Constructs a newStringby decoding the specified array of bytes using the
175 platform's default charset. The length of the newStringis a function of the
176 charset, and hence may not be equal to the length of the byte array.
178 The behavior of this constructor when the given bytes are not valid in the
179 default charset is unspecified. The (|java.nio.charset.CharsetDecoder|) class
180 should be used when more control over the decoding process is required.
182 bytes - The bytes to be decoded into characters
184 *java.lang.String(byte[],Charset)*
188 java.nio.charset.Charset charset)
190 Constructs a newStringby decoding the specified array of bytes using the
191 specified charset(|java.nio.charset.Charset|) . The length of the newStringis a
192 function of the charset, and hence may not be equal to the length of the byte
195 This method always replaces malformed-input and unmappable-character sequences
196 with this charset's default replacement string. The
197 (|java.nio.charset.CharsetDecoder|) class should be used when more control over
198 the decoding process is required.
200 bytes - The bytes to be decoded into characters
201 charset - The {@linkplain java.nio.charset.Charset charset} to be used to decode the
204 *java.lang.String(byte[],int)*
210 Allocates a newStringcontaining characters constructed from an array of 8-bit
211 integer values. Each character cin the resulting string is constructed from the
212 corresponding component b in the byte array such that:
216 c == (char)(((hibyte and 0xff) << 8) | (b and 0xff))
218 ascii - The bytes to be converted to characters
219 hibyte - The top 8 bits of each 16-bit Unicode code unit
221 *java.lang.String(byte[],int,int)*
228 Constructs a newStringby decoding the specified subarray of bytes using the
229 platform's default charset. The length of the newStringis a function of the
230 charset, and hence may not be equal to the length of the subarray.
232 The behavior of this constructor when the given bytes are not valid in the
233 default charset is unspecified. The (|java.nio.charset.CharsetDecoder|) class
234 should be used when more control over the decoding process is required.
236 bytes - The bytes to be decoded into characters
237 offset - The index of the first byte to decode
238 length - The number of bytes to decode
240 *java.lang.String(byte[],int,int,Charset)*
246 java.nio.charset.Charset charset)
248 Constructs a newStringby decoding the specified subarray of bytes using the
249 specified charset(|java.nio.charset.Charset|) . The length of the newStringis a
250 function of the charset, and hence may not be equal to the length of the
253 This method always replaces malformed-input and unmappable-character sequences
254 with this charset's default replacement string. The
255 (|java.nio.charset.CharsetDecoder|) class should be used when more control over
256 the decoding process is required.
258 bytes - The bytes to be decoded into characters
259 offset - The index of the first byte to decode
260 length - The number of bytes to decode
261 charset - The {@linkplain java.nio.charset.Charset charset} to be used to decode the
264 *java.lang.String(byte[],int,int,int)*
272 Allocates a newStringconstructed from a subarray of an array of 8-bit integer
275 Theoffsetargument is the index of the first byte of the subarray, and
276 thecountargument specifies the length of the subarray.
278 Eachbytein the subarray is converted to acharas specified in the method above.
280 ascii - The bytes to be converted to characters
281 hibyte - The top 8 bits of each 16-bit Unicode code unit
282 offset - The initial offset
285 *java.lang.String(byte[],int,int,String)*
291 java.lang.String charsetName)
292 throws |java.io.UnsupportedEncodingException|
294 Constructs a newStringby decoding the specified subarray of bytes using the
295 specified charset. The length of the newStringis a function of the charset, and
296 hence may not be equal to the length of the subarray.
298 The behavior of this constructor when the given bytes are not valid in the
299 given charset is unspecified. The (|java.nio.charset.CharsetDecoder|) class
300 should be used when more control over the decoding process is required.
302 bytes - The bytes to be decoded into characters
303 offset - The index of the first byte to decode
304 length - The number of bytes to decode
305 charsetName - The name of a supported {@linkplain java.nio.charset.Charset charset}
307 *java.lang.String(byte[],String)*
311 java.lang.String charsetName)
312 throws |java.io.UnsupportedEncodingException|
314 Constructs a newStringby decoding the specified array of bytes using the
315 specified charset(|java.nio.charset.Charset|) . The length of the newStringis a
316 function of the charset, and hence may not be equal to the length of the byte
319 The behavior of this constructor when the given bytes are not valid in the
320 given charset is unspecified. The (|java.nio.charset.CharsetDecoder|) class
321 should be used when more control over the decoding process is required.
323 bytes - The bytes to be decoded into characters
324 charsetName - The name of a supported {@linkplain java.nio.charset.Charset charset}
326 *java.lang.String(char[])*
328 public String(char[] value)
330 Allocates a newStringso that it represents the sequence of characters currently
331 contained in the character array argument. The contents of the character array
332 are copied; subsequent modification of the character array does not affect the
333 newly created string.
335 value - The initial value of the string
337 *java.lang.String(char[],int,int)*
344 Allocates a newStringthat contains characters from a subarray of the character
345 array argument. Theoffsetargument is the index of the first character of the
346 subarray and thecountargument specifies the length of the subarray. The
347 contents of the subarray are copied; subsequent modification of the character
348 array does not affect the newly created string.
350 value - Array that is the source of characters
351 offset - The initial offset
354 *java.lang.String(int[],int,int)*
361 Allocates a newStringthat contains characters from a subarray of the Unicode
362 code point array argument. Theoffsetargument is the index of the first code
363 point of the subarray and thecountargument specifies the length of the
364 subarray. The contents of the subarray are converted tochars; subsequent
365 modification of theintarray does not affect the newly created string.
367 codePoints - Array that is the source of Unicode code points
368 offset - The initial offset
371 *java.lang.String(String)*
373 public String(java.lang.String original)
375 Initializes a newly createdStringobject so that it represents the same sequence
376 of characters as the argument; in other words, the newly created string is a
377 copy of the argument string. Unless an explicit copy oforiginalis needed, use
378 of this constructor is unnecessary since Strings are immutable.
380 original - A {@code String}
382 *java.lang.String(StringBuffer)*
384 public String(java.lang.StringBuffer buffer)
386 Allocates a new string that contains the sequence of characters currently
387 contained in the string buffer argument. The contents of the string buffer are
388 copied; subsequent modification of the string buffer does not affect the newly
391 buffer - A {@code StringBuffer}
393 *java.lang.String(StringBuilder)*
395 public String(java.lang.StringBuilder builder)
397 Allocates a new string that contains the sequence of characters currently
398 contained in the string builder argument. The contents of the string builder
399 are copied; subsequent modification of the string builder does not affect the
400 newly created string.
402 This constructor is provided to ease migration toStringBuilder. Obtaining a
403 string from a string builder via thetoStringmethod is likely to run faster and
404 is generally preferred.
406 builder - A {@code StringBuilder}
408 *java.lang.String.charAt(int)*
410 public char charAt(int index)
412 Returns the char value at the specified index. An index ranges from 0 to
413 length() - 1. The first char value of the sequence is at index 0, the next at
414 index 1, and so on, as for array indexing.
416 If the char value specified by the index is a surrogate, the surrogate value is
420 index - the index of the char value.
422 Returns: the char value at the specified index of this string. The first char value is
425 *java.lang.String.codePointAt(int)*
427 public int codePointAt(int index)
429 Returns the character (Unicode code point) at the specified index. The index
430 refers to char values (Unicode code units) and ranges from 0 to
431 (|java.lang.String|) - 1.
433 If the char value specified at the given index is in the high-surrogate range,
434 the following index is less than the length of this String, and the char value
435 at the following index is in the low-surrogate range, then the supplementary
436 code point corresponding to this surrogate pair is returned. Otherwise, the
437 char value at the given index is returned.
440 index - the index to the char values
442 Returns: the code point value of the character at the index
444 *java.lang.String.codePointBefore(int)*
446 public int codePointBefore(int index)
448 Returns the character (Unicode code point) before the specified index. The
449 index refers to char values (Unicode code units) and ranges from 1 to
450 length(|java.lang.CharSequence|) .
452 If the char value at (index - 1) is in the low-surrogate range, (index - 2) is
453 not negative, and the char value at (index - 2) is in the high-surrogate range,
454 then the supplementary code point value of the surrogate pair is returned. If
455 the char value at index - 1 is an unpaired low-surrogate or a high-surrogate,
456 the surrogate value is returned.
459 index - the index following the code point that should be returned
461 Returns: the Unicode code point value before the given index.
463 *java.lang.String.codePointCount(int,int)*
465 public int codePointCount(
469 Returns the number of Unicode code points in the specified text range of this
470 String. The text range begins at the specified beginIndex and extends to the
471 char at index endIndex - 1. Thus the length (in chars) of the text range is
472 endIndex-beginIndex. Unpaired surrogates within the text range count as one
476 beginIndex - the index to the first char of the text range.
477 endIndex - the index after the last char of the text range.
479 Returns: the number of Unicode code points in the specified text range
481 *java.lang.String.compareTo(String)*
483 public int compareTo(java.lang.String anotherString)
485 Compares two strings lexicographically. The comparison is based on the Unicode
486 value of each character in the strings. The character sequence represented by
487 this String object is compared lexicographically to the character sequence
488 represented by the argument string. The result is a negative integer if this
489 String object lexicographically precedes the argument string. The result is a
490 positive integer if this String object lexicographically follows the argument
491 string. The result is zero if the strings are equal; compareTo returns 0
492 exactly when the (|java.lang.String|) method would return true.
494 This is the definition of lexicographic ordering. If two strings are different,
495 then either they have different characters at some index that is a valid index
496 for both strings, or their lengths are different, or both. If they have
497 different characters at one or more index positions, let k be the smallest such
498 index; then the string whose character at position k has the smaller value, as
499 determined by using the < operator, lexicographically precedes the other
500 string. In this case, compareTo returns the difference of the two character
501 values at position k in the two string -- that is, the value:
503 this.charAt(k)-anotherString.charAt(k)
505 If there is no index position at which they differ, then the shorter string
506 lexicographically precedes the longer string. In this case, compareTo returns
507 the difference of the lengths of the strings -- that is, the value:
509 this.length()-anotherString.length()
512 anotherString - the String to be compared.
514 Returns: the value 0 if the argument string is equal to this string; a value less than 0
515 if this string is lexicographically less than the string argument;
516 and a value greater than 0 if this string is lexicographically
517 greater than the string argument.
519 *java.lang.String.compareToIgnoreCase(String)*
521 public int compareToIgnoreCase(java.lang.String str)
523 Compares two strings lexicographically, ignoring case differences. This method
524 returns an integer whose sign is that of calling compareTo with normalized
525 versions of the strings where case differences have been eliminated by calling
526 Character.toLowerCase(Character.toUpperCase(character)) on each character.
528 Note that this method does not take locale into account, and will result in an
529 unsatisfactory ordering for certain locales. The java.text package provides
530 collators to allow locale-sensitive ordering.
533 str - the String to be compared.
535 Returns: a negative integer, zero, or a positive integer as the specified String is
536 greater than, equal to, or less than this String, ignoring case
539 *java.lang.String.concat(String)*
541 public |java.lang.String| concat(java.lang.String str)
543 Concatenates the specified string to the end of this string.
545 If the length of the argument string is 0, then this String object is returned.
546 Otherwise, a new String object is created, representing a character sequence
547 that is the concatenation of the character sequence represented by this String
548 object and the character sequence represented by the argument string. Examples:
550 "cares".concat("s") returns "caress" "to".concat("get").concat("her") returns
554 str - the String that is concatenated to the end of this String.
556 Returns: a string that represents the concatenation of this object's characters followed
557 by the string argument's characters.
559 *java.lang.String.contains(CharSequence)*
561 public boolean contains(java.lang.CharSequence s)
563 Returns true if and only if this string contains the specified sequence of char
567 s - the sequence to search for
569 Returns: true if this string contains s, false otherwise
571 *java.lang.String.contentEquals(CharSequence)*
573 public boolean contentEquals(java.lang.CharSequence cs)
575 Compares this string to the specifiedCharSequence. The result istrueif and only
576 if thisStringrepresents the same sequence of char values as the specified
580 cs - The sequence to compare this {@code String} against
582 Returns: {@code true} if this {@code String} represents the same sequence of char values
583 as the specified sequence, {@code false} otherwise
585 *java.lang.String.contentEquals(StringBuffer)*
587 public boolean contentEquals(java.lang.StringBuffer sb)
589 Compares this string to the specifiedStringBuffer. The result istrueif and only
590 if thisStringrepresents the same sequence of characters as the
591 specifiedStringBuffer.
594 sb - The {@code StringBuffer} to compare this {@code String} against
596 Returns: {@code true} if this {@code String} represents the same sequence of characters
597 as the specified {@code StringBuffer}, {@code false} otherwise
599 *java.lang.String.copyValueOf(char[])*
601 public static |java.lang.String| copyValueOf(char[] data)
603 Returns a String that represents the character sequence in the array specified.
606 data - the character array.
608 Returns: a String that contains the characters of the character array.
610 *java.lang.String.copyValueOf(char[],int,int)*
612 public static |java.lang.String| copyValueOf(
617 Returns a String that represents the character sequence in the array specified.
620 data - the character array.
621 offset - initial offset of the subarray.
622 count - length of the subarray.
624 Returns: a String that contains the characters of the specified subarray of the
627 *java.lang.String.endsWith(String)*
629 public boolean endsWith(java.lang.String suffix)
631 Tests if this string ends with the specified suffix.
636 Returns: true if the character sequence represented by the argument is a suffix of the
637 character sequence represented by this object; false otherwise.
638 Note that the result will be true if the argument is the empty
639 string or is equal to this String object as determined by the
640 {@link #equals(Object)} method.
642 *java.lang.String.equals(Object)*
644 public boolean equals(java.lang.Object anObject)
646 Compares this string to the specified object. The result istrueif and only if
647 the argument is notnulland is aStringobject that represents the same sequence
648 of characters as this object.
651 anObject - The object to compare this {@code String} against
653 Returns: {@code true} if the given object represents a {@code String} equivalent to this
654 string, {@code false} otherwise
656 *java.lang.String.equalsIgnoreCase(String)*
658 public boolean equalsIgnoreCase(java.lang.String anotherString)
660 Compares thisStringto anotherString, ignoring case considerations. Two strings
661 are considered equal ignoring case if they are of the same length and
662 corresponding characters in the two strings are equal ignoring case.
664 Two charactersc1andc2are considered the same ignoring case if at least one of
665 the following is true:
667 The two characters are the same (as compared by the==operator) Applying the
668 method (|java.lang.Character|) to each character produces the same result
669 Applying the method (|java.lang.Character|) to each character produces the same
673 anotherString - The {@code String} to compare this {@code String} against
675 Returns: {@code true} if the argument is not {@code null} and it represents an
676 equivalent {@code String} ignoring case; {@code false} otherwise
678 *java.lang.String.format(Locale,String,Object...)*
680 public static |java.lang.String| format(
682 java.lang.String format,
683 java.lang.Object[] args)
685 Returns a formatted string using the specified locale, format string, and
689 l - The {@linkplain java.util.Locale locale} to apply during formatting. If l is
690 null then no localization is applied.
691 format - A format string
692 args - Arguments referenced by the format specifiers in the format string. If there
693 are more arguments than format specifiers, the extra arguments are
694 ignored. The number of arguments is variable and may be zero. The
695 maximum number of arguments is limited by the maximum dimension of a
696 Java array as defined by the Java Virtual Machine Specification. The
697 behaviour on a null argument depends on the conversion.
699 Returns: A formatted string
701 *java.lang.String.format(String,Object...)*
703 public static |java.lang.String| format(
704 java.lang.String format,
705 java.lang.Object[] args)
707 Returns a formatted string using the specified format string and arguments.
709 The locale always used is the one returned by
710 Locale.getDefault()(|java.util.Locale|) .
713 format - A format string
714 args - Arguments referenced by the format specifiers in the format string. If there
715 are more arguments than format specifiers, the extra arguments are
716 ignored. The number of arguments is variable and may be zero. The
717 maximum number of arguments is limited by the maximum dimension of a
718 Java array as defined by the Java Virtual Machine Specification. The
719 behaviour on a null argument depends on the conversion.
721 Returns: A formatted string
723 *java.lang.String.getBytes()*
725 public byte[] getBytes()
727 Encodes thisStringinto a sequence of bytes using the platform's default
728 charset, storing the result into a new byte array.
730 The behavior of this method when this string cannot be encoded in the default
731 charset is unspecified. The (|java.nio.charset.CharsetEncoder|) class should be
732 used when more control over the encoding process is required.
736 Returns: The resultant byte array
738 *java.lang.String.getBytes(Charset)*
740 public byte[] getBytes(java.nio.charset.Charset charset)
742 Encodes thisStringinto a sequence of bytes using the given
743 charset(|java.nio.charset.Charset|) , storing the result into a new byte array.
745 This method always replaces malformed-input and unmappable-character sequences
746 with this charset's default replacement byte array. The
747 (|java.nio.charset.CharsetEncoder|) class should be used when more control over
748 the encoding process is required.
751 charset - The {@linkplain java.nio.charset.Charset} to be used to encode the {@code
754 Returns: The resultant byte array
756 *java.lang.String.getBytes(int,int,byte[],int)*
758 public void getBytes(
764 Copies characters from this string into the destination byte array. Each byte
765 receives the 8 low-order bits of the corresponding character. The eight
766 high-order bits of each character are not copied and do not participate in the
769 The first character to be copied is at indexsrcBegin; the last character to be
770 copied is at indexsrcEnd-1. The total number of characters to be copied
771 issrcEnd-srcBegin. The characters, converted to bytes, are copied into the
772 subarray ofdststarting at indexdstBeginand ending at index:
776 dstbegin + (srcEnd-srcBegin) - 1
778 Deprecated: This method does not properly convert characters into
779 bytes. As of JDK 1.1, the preferred way to do this is via the
780 {@link #getBytes()} method, which uses the platform's default charset.
782 srcBegin - Index of the first character in the string to copy
783 srcEnd - Index after the last character in the string to copy
784 dst - The destination array
785 dstBegin - The start offset in the destination array
787 *java.lang.String.getBytes(String)*
789 public byte[] getBytes(java.lang.String charsetName)
790 throws |java.io.UnsupportedEncodingException|
792 Encodes thisStringinto a sequence of bytes using the named charset, storing the
793 result into a new byte array.
795 The behavior of this method when this string cannot be encoded in the given
796 charset is unspecified. The (|java.nio.charset.CharsetEncoder|) class should be
797 used when more control over the encoding process is required.
800 charsetName - The name of a supported {@linkplain java.nio.charset.Charset charset}
802 Returns: The resultant byte array
804 *java.lang.String.getChars(int,int,char[],int)*
806 public void getChars(
812 Copies characters from this string into the destination character array.
814 The first character to be copied is at index srcBegin; the last character to be
815 copied is at index srcEnd-1 (thus the total number of characters to be copied
816 is srcEnd-srcBegin). The characters are copied into the subarray of dst
817 starting at index dstBegin and ending at index:
819 dstbegin + (srcEnd-srcBegin) - 1
822 srcBegin - index of the first character in the string to copy.
823 srcEnd - index after the last character in the string to copy.
824 dst - the destination array.
825 dstBegin - the start offset in the destination array.
827 *java.lang.String.hashCode()*
829 public int hashCode()
831 Returns a hash code for this string. The hash code for a String object is
834 s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
836 using int arithmetic, where s[i] is the ith character of the string, n is the
837 length of the string, and ^ indicates exponentiation. (The hash value of the
838 empty string is zero.)
842 Returns: a hash code value for this object.
844 *java.lang.String.indexOf(int)*
846 public int indexOf(int ch)
848 Returns the index within this string of the first occurrence of the specified
849 character. If a character with value ch occurs in the character sequence
850 represented by this String object, then the index (in Unicode code units) of
851 the first such occurrence is returned. For values of ch in the range from 0 to
852 0xFFFF (inclusive), this is the smallest value k such that:
856 is true. For other values of ch, it is the smallest value k such that:
858 this.codePointAt(k) == ch
860 is true. In either case, if no such character occurs in this string, then -1 is
864 ch - a character (Unicode code point).
866 Returns: the index of the first occurrence of the character in the character sequence
867 represented by this object, or -1 if the character does not occur.
869 *java.lang.String.indexOf(int,int)*
875 Returns the index within this string of the first occurrence of the specified
876 character, starting the search at the specified index.
878 If a character with value ch occurs in the character sequence represented by
879 this String object at an index no smaller than fromIndex, then the index of the
880 first such occurrence is returned. For values of ch in the range from 0 to
881 0xFFFF (inclusive), this is the smallest value k such that:
883 (this.charAt(k) == ch) (k >= fromIndex)
885 is true. For other values of ch, it is the smallest value k such that:
887 (this.codePointAt(k) == ch) (k >= fromIndex)
889 is true. In either case, if no such character occurs in this string at or after
890 position fromIndex, then -1 is returned.
892 There is no restriction on the value of fromIndex. If it is negative, it has
893 the same effect as if it were zero: this entire string may be searched. If it
894 is greater than the length of this string, it has the same effect as if it were
895 equal to the length of this string: -1 is returned.
897 All indices are specified in char values (Unicode code units).
900 ch - a character (Unicode code point).
901 fromIndex - the index to start the search from.
903 Returns: the index of the first occurrence of the character in the character sequence
904 represented by this object that is greater than or equal to
905 fromIndex, or -1 if the character does not occur.
907 *java.lang.String.indexOf(String)*
909 public int indexOf(java.lang.String str)
911 Returns the index within this string of the first occurrence of the specified
912 substring. The integer returned is the smallest value k such that:
914 this.startsWith(str, k)
921 Returns: if the string argument occurs as a substring within this object, then the index
922 of the first character of the first such substring is returned; if
923 it does not occur as a substring, -1 is returned.
925 *java.lang.String.indexOf(String,int)*
928 java.lang.String str,
931 Returns the index within this string of the first occurrence of the specified
932 substring, starting at the specified index. The integer returned is the
933 smallest value k for which:
935 k >= Math.min(fromIndex, this.length()) this.startsWith(str, k)
937 If no such value of k exists, then -1 is returned.
940 str - the substring for which to search.
941 fromIndex - the index from which to start the search.
943 Returns: the index within this string of the first occurrence of the specified
944 substring, starting at the specified index.
946 *java.lang.String.intern()*
948 public native |java.lang.String| intern()
950 Returns a canonical representation for the string object.
952 A pool of strings, initially empty, is maintained privately by the class
955 When the intern method is invoked, if the pool already contains a string equal
956 to this String object as determined by the (|java.lang.String|) method, then
957 the string from the pool is returned. Otherwise, this String object is added to
958 the pool and a reference to this String object is returned.
960 It follows that for any two strings s and t, s.intern()==t.intern() is true if
961 and only if s.equals(t) is true.
963 All literal strings and string-valued constant expressions are interned. String
964 literals are defined in 3.10.5 of the Java Language Specification
968 Returns: a string that has the same contents as this string, but is guaranteed to be
969 from a pool of unique strings.
971 *java.lang.String.isEmpty()*
973 public boolean isEmpty()
975 Returns true if, and only if, (|java.lang.String|) is 0.
979 Returns: true if {@link #length()} is 0, otherwise false
981 *java.lang.String.lastIndexOf(int)*
983 public int lastIndexOf(int ch)
985 Returns the index within this string of the last occurrence of the specified
986 character. For values of ch in the range from 0 to 0xFFFF (inclusive), the
987 index (in Unicode code units) returned is the largest value k such that:
991 is true. For other values of ch, it is the largest value k such that:
993 this.codePointAt(k) == ch
995 is true. In either case, if no such character occurs in this string, then -1 is
996 returned. The String is searched backwards starting at the last character.
999 ch - a character (Unicode code point).
1001 Returns: the index of the last occurrence of the character in the character sequence
1002 represented by this object, or -1 if the character does not occur.
1004 *java.lang.String.lastIndexOf(int,int)*
1006 public int lastIndexOf(
1010 Returns the index within this string of the last occurrence of the specified
1011 character, searching backward starting at the specified index. For values of ch
1012 in the range from 0 to 0xFFFF (inclusive), the index returned is the largest
1015 (this.charAt(k) == ch) (k <= fromIndex)
1017 is true. For other values of ch, it is the largest value k such that:
1019 (this.codePointAt(k) == ch) (k <= fromIndex)
1021 is true. In either case, if no such character occurs in this string at or
1022 before position fromIndex, then -1 is returned.
1024 All indices are specified in char values (Unicode code units).
1027 ch - a character (Unicode code point).
1028 fromIndex - the index to start the search from. There is no restriction on the value of
1029 fromIndex. If it is greater than or equal to the length of this string,
1030 it has the same effect as if it were equal to one less than the length
1031 of this string: this entire string may be searched. If it is negative,
1032 it has the same effect as if it were -1: -1 is returned.
1034 Returns: the index of the last occurrence of the character in the character sequence
1035 represented by this object that is less than or equal to
1036 fromIndex, or -1 if the character does not occur before that
1039 *java.lang.String.lastIndexOf(String)*
1041 public int lastIndexOf(java.lang.String str)
1043 Returns the index within this string of the rightmost occurrence of the
1044 specified substring. The rightmost empty string "" is considered to occur at
1045 the index value this.length(). The returned index is the largest value k such
1048 this.startsWith(str, k)
1053 str - the substring to search for.
1055 Returns: if the string argument occurs one or more times as a substring within this
1056 object, then the index of the first character of the last such
1057 substring is returned. If it does not occur as a substring, -1 is
1060 *java.lang.String.lastIndexOf(String,int)*
1062 public int lastIndexOf(
1063 java.lang.String str,
1066 Returns the index within this string of the last occurrence of the specified
1067 substring, searching backward starting at the specified index. The integer
1068 returned is the largest value k such that:
1070 k <= Math.min(fromIndex, this.length()) this.startsWith(str, k)
1072 If no such value of k exists, then -1 is returned.
1075 str - the substring to search for.
1076 fromIndex - the index to start the search from.
1078 Returns: the index within this string of the last occurrence of the specified substring.
1080 *java.lang.String.length()*
1084 Returns the length of this string. The length is equal to the number of Unicode
1085 code units in the string.
1089 Returns: the length of the sequence of characters represented by this object.
1091 *java.lang.String.matches(String)*
1093 public boolean matches(java.lang.String regex)
1095 Tells whether or not this string matches the given regular expression.
1097 An invocation of this method of the form str.matches(regex) yields exactly the
1098 same result as the expression
1100 (|java.util.regex.Pattern|) . matches(|java.util.regex.Pattern|) (regex, str)
1103 regex - the regular expression to which this string is to be matched
1105 Returns: true if, and only if, this string matches the given regular expression
1107 *java.lang.String.offsetByCodePoints(int,int)*
1109 public int offsetByCodePoints(
1111 int codePointOffset)
1113 Returns the index within this String that is offset from the given index by
1114 codePointOffset code points. Unpaired surrogates within the text range given by
1115 index and codePointOffset count as one code point each.
1118 index - the index to be offset
1119 codePointOffset - the offset in code points
1121 Returns: the index within this String
1123 *java.lang.String.regionMatches(boolean,int,String,int,int)*
1125 public boolean regionMatches(
1128 java.lang.String other,
1132 Tests if two string regions are equal.
1134 A substring of this String object is compared to a substring of the argument
1135 other. The result is true if these substrings represent character sequences
1136 that are the same, ignoring case if and only if ignoreCase is true. The
1137 substring of this String object to be compared begins at index toffset and has
1138 length len. The substring of other to be compared begins at index ooffset and
1139 has length len. The result is false if and only if at least one of the
1140 following is true: toffset is negative. ooffset is negative. toffset+len is
1141 greater than the length of this String object. ooffset+len is greater than the
1142 length of the other argument. ignoreCase is false and there is some nonnegative
1143 integer k less than len such that:
1145 this.charAt(toffset+k) != other.charAt(ooffset+k)
1147 ignoreCase is true and there is some nonnegative integer k less than len such
1150 Character.toLowerCase(this.charAt(toffset+k)) !=
1151 Character.toLowerCase(other.charAt(ooffset+k))
1155 Character.toUpperCase(this.charAt(toffset+k)) !=
1156 Character.toUpperCase(other.charAt(ooffset+k))
1161 ignoreCase - if true, ignore case when comparing characters.
1162 toffset - the starting offset of the subregion in this string.
1163 other - the string argument.
1164 ooffset - the starting offset of the subregion in the string argument.
1165 len - the number of characters to compare.
1167 Returns: true if the specified subregion of this string matches the specified subregion
1168 of the string argument; false otherwise. Whether the matching is
1169 exact or case insensitive depends on the ignoreCase argument.
1171 *java.lang.String.regionMatches(int,String,int,int)*
1173 public boolean regionMatches(
1175 java.lang.String other,
1179 Tests if two string regions are equal.
1181 A substring of this String object is compared to a substring of the argument
1182 other. The result is true if these substrings represent identical character
1183 sequences. The substring of this String object to be compared begins at index
1184 toffset and has length len. The substring of other to be compared begins at
1185 index ooffset and has length len. The result is false if and only if at least
1186 one of the following is true: toffset is negative. ooffset is negative.
1187 toffset+len is greater than the length of this String object. ooffset+len is
1188 greater than the length of the other argument. There is some nonnegative
1189 integer k less than len such that:
1190 this.charAt(toffset+k)!=other.charAt(ooffset+k)
1193 toffset - the starting offset of the subregion in this string.
1194 other - the string argument.
1195 ooffset - the starting offset of the subregion in the string argument.
1196 len - the number of characters to compare.
1198 Returns: true if the specified subregion of this string exactly matches the specified
1199 subregion of the string argument; false otherwise.
1201 *java.lang.String.replace(char,char)*
1203 public |java.lang.String| replace(
1207 Returns a new string resulting from replacing all occurrences of oldChar in
1208 this string with newChar.
1210 If the character oldChar does not occur in the character sequence represented
1211 by this String object, then a reference to this String object is returned.
1212 Otherwise, a new String object is created that represents a character sequence
1213 identical to the character sequence represented by this String object, except
1214 that every occurrence of oldChar is replaced by an occurrence of newChar.
1218 "mesquite in your cellar".replace('e', 'o') returns "mosquito in your collar"
1219 "the war of baronets".replace('r', 'y') returns "the way of bayonets" "sparring
1220 with a purple porpoise".replace('p', 't') returns "starring with a turtle
1221 tortoise" "JonL".replace('q', 'x') returns "JonL" (no change)
1224 oldChar - the old character.
1225 newChar - the new character.
1227 Returns: a string derived from this string by replacing every occurrence of oldChar with
1230 *java.lang.String.replace(CharSequence,CharSequence)*
1232 public |java.lang.String| replace(
1233 java.lang.CharSequence target,
1234 java.lang.CharSequence replacement)
1236 Replaces each substring of this string that matches the literal target sequence
1237 with the specified literal replacement sequence. The replacement proceeds from
1238 the beginning of the string to the end, for example, replacing "aa" with "b" in
1239 the string "aaa" will result in "ba" rather than "ab".
1242 target - The sequence of char values to be replaced
1243 replacement - The replacement sequence of char values
1245 Returns: The resulting string
1247 *java.lang.String.replaceAll(String,String)*
1249 public |java.lang.String| replaceAll(
1250 java.lang.String regex,
1251 java.lang.String replacement)
1253 Replaces each substring of this string that matches the given regular
1254 expression with the given replacement.
1256 An invocation of this method of the form str.replaceAll(regex, repl) yields
1257 exactly the same result as the expression
1259 (|java.util.regex.Pattern|) . compile(|java.util.regex.Pattern|) (regex).
1260 matcher(|java.util.regex.Pattern|) (str). replaceAll(|java.util.regex.Matcher|)
1263 Note that backslashes (\) and dollar signs ($) in the replacement string may
1264 cause the results to be different than if it were being treated as a literal
1265 replacement string; see Matcher.replaceAll(|java.util.regex.Matcher|) . Use
1266 (|java.util.regex.Matcher|) to suppress the special meaning of these
1267 characters, if desired.
1270 regex - the regular expression to which this string is to be matched
1271 replacement - the string to be substituted for each match
1273 Returns: The resulting String
1275 *java.lang.String.replaceFirst(String,String)*
1277 public |java.lang.String| replaceFirst(
1278 java.lang.String regex,
1279 java.lang.String replacement)
1281 Replaces the first substring of this string that matches the given regular
1282 expression with the given replacement.
1284 An invocation of this method of the form str.replaceFirst(regex, repl) yields
1285 exactly the same result as the expression
1287 (|java.util.regex.Pattern|) . compile(|java.util.regex.Pattern|) (regex).
1288 matcher(|java.util.regex.Pattern|) (str).
1289 replaceFirst(|java.util.regex.Matcher|) (repl)
1291 Note that backslashes (\) and dollar signs ($) in the replacement string may
1292 cause the results to be different than if it were being treated as a literal
1293 replacement string; see (|java.util.regex.Matcher|) . Use
1294 (|java.util.regex.Matcher|) to suppress the special meaning of these
1295 characters, if desired.
1298 regex - the regular expression to which this string is to be matched
1299 replacement - the string to be substituted for the first match
1301 Returns: The resulting String
1303 *java.lang.String.split(String)*
1305 public |java.lang.String|[] split(java.lang.String regex)
1307 Splits this string around matches of the given regular expression.
1309 This method works as if by invoking the two-argument split(|java.lang.String|)
1310 method with the given expression and a limit argument of zero. Trailing empty
1311 strings are therefore not included in the resulting array.
1313 The string "boo:and:foo", for example, yields the following results with these
1320 : { "boo", "and", "foo" } o { "b", "", ":and:f" }
1323 regex - the delimiting regular expression
1325 Returns: the array of strings computed by splitting this string around matches of the
1326 given regular expression
1328 *java.lang.String.split(String,int)*
1330 public |java.lang.String|[] split(
1331 java.lang.String regex,
1334 Splits this string around matches of the given regular expression.
1336 The array returned by this method contains each substring of this string that
1337 is terminated by another substring that matches the given expression or is
1338 terminated by the end of the string. The substrings in the array are in the
1339 order in which they occur in this string. If the expression does not match any
1340 part of the input then the resulting array has just one element, namely this
1343 The limit parameter controls the number of times the pattern is applied and
1344 therefore affects the length of the resulting array. If the limit n is greater
1345 than zero then the pattern will be applied at most n-1 times, the array's
1346 length will be no greater than n, and the array's last entry will contain all
1347 input beyond the last matched delimiter. If n is non-positive then the pattern
1348 will be applied as many times as possible and the array can have any length. If
1349 n is zero then the pattern will be applied as many times as possible, the array
1350 can have any length, and trailing empty strings will be discarded.
1352 The string "boo:and:foo", for example, yields the following results with these
1359 : 2 { "boo", "and:foo" } : 5 { "boo", "and", "foo" } : -2 { "boo", "and", "foo"
1360 } o 5 { "b", "", ":and:f", "", "" } o -2 { "b", "", ":and:f", "", "" } o 0 {
1363 An invocation of this method of the form str.split(regex,n) yields the same
1364 result as the expression
1366 (|java.util.regex.Pattern|) . compile(|java.util.regex.Pattern|) (regex).
1367 split(|java.util.regex.Pattern|) (str,n)
1370 regex - the delimiting regular expression
1371 limit - the result threshold, as described above
1373 Returns: the array of strings computed by splitting this string around matches of the
1374 given regular expression
1376 *java.lang.String.startsWith(String)*
1378 public boolean startsWith(java.lang.String prefix)
1380 Tests if this string starts with the specified prefix.
1383 prefix - the prefix.
1385 Returns: true if the character sequence represented by the argument is a prefix of the
1386 character sequence represented by this string; false otherwise.
1387 Note also that true will be returned if the argument is an empty
1388 string or is equal to this String object as determined by the
1389 {@link #equals(Object)} method.
1391 *java.lang.String.startsWith(String,int)*
1393 public boolean startsWith(
1394 java.lang.String prefix,
1397 Tests if the substring of this string beginning at the specified index starts
1398 with the specified prefix.
1401 prefix - the prefix.
1402 toffset - where to begin looking in this string.
1404 Returns: true if the character sequence represented by the argument is a prefix of the
1405 substring of this object starting at index toffset; false
1406 otherwise. The result is false if toffset is negative or greater
1407 than the length of this String object; otherwise the result is the
1408 same as the result of the expression
1410 this.substring(toffset).startsWith(prefix)
1412 *java.lang.String.subSequence(int,int)*
1414 public |java.lang.CharSequence| subSequence(
1418 Returns a new character sequence that is a subsequence of this sequence.
1420 An invocation of this method of the form
1424 str.subSequence(begin,end)
1426 behaves in exactly the same way as the invocation
1430 str.substring(begin,end)
1432 This method is defined so that the String class can implement the
1433 (|java.lang.CharSequence|) interface.
1436 beginIndex - the begin index, inclusive.
1437 endIndex - the end index, exclusive.
1439 Returns: the specified subsequence.
1441 *java.lang.String.substring(int)*
1443 public |java.lang.String| substring(int beginIndex)
1445 Returns a new string that is a substring of this string. The substring begins
1446 with the character at the specified index and extends to the end of this
1449 "unhappy".substring(2) returns "happy" "Harbison".substring(3) returns "bison"
1450 "emptiness".substring(9) returns "" (an empty string)
1453 beginIndex - the beginning index, inclusive.
1455 Returns: the specified substring.
1457 *java.lang.String.substring(int,int)*
1459 public |java.lang.String| substring(
1463 Returns a new string that is a substring of this string. The substring begins
1464 at the specified beginIndex and extends to the character at index endIndex - 1.
1465 Thus the length of the substring is endIndex-beginIndex.
1469 "hamburger".substring(4, 8) returns "urge" "smiles".substring(1, 5) returns
1473 beginIndex - the beginning index, inclusive.
1474 endIndex - the ending index, exclusive.
1476 Returns: the specified substring.
1478 *java.lang.String.toCharArray()*
1480 public char[] toCharArray()
1482 Converts this string to a new character array.
1486 Returns: a newly allocated character array whose length is the length of this string and
1487 whose contents are initialized to contain the character sequence
1488 represented by this string.
1490 *java.lang.String.toLowerCase()*
1492 public |java.lang.String| toLowerCase()
1494 Converts all of the characters in this String to lower case using the rules of
1495 the default locale. This is equivalent to calling
1496 toLowerCase(Locale.getDefault()).
1498 Note: This method is locale sensitive, and may produce unexpected results if
1499 used for strings that are intended to be interpreted locale independently.
1500 Examples are programming language identifiers, protocol keys, and HTML tags.
1501 For instance, "TITLE".toLowerCase() in a Turkish locale returns "tõtle", where
1502 'õ' is the LATIN SMALL LETTER DOTLESS I character. To obtain correct results
1503 for locale insensitive strings, use toLowerCase(Locale.ENGLISH).
1507 Returns: the String, converted to lowercase.
1509 *java.lang.String.toLowerCase(Locale)*
1511 public |java.lang.String| toLowerCase(java.util.Locale locale)
1513 Converts all of the characters in this String to lower case using the rules of
1514 the given Locale. Case mapping is based on the Unicode Standard version
1515 specified by the Character(|java.lang.Character|) class. Since case mappings
1516 are not always 1:1 char mappings, the resulting String may be a different
1517 length than the original String.
1519 Examples of lowercase mappings are in the following table:
1521 Language Code of Locale Upper Case Lower Case Description
1523 tr (Turkish) u0130 u0069 capital letter I with dot above -> small letter i
1525 tr (Turkish) u0049 u0131 capital letter I -> small letter dotless i
1527 (all) French Fries french fries lowercased all chars in String
1535 lowercased all chars in String
1540 locale - use the case transformation rules for this locale
1542 Returns: the String, converted to lowercase.
1544 *java.lang.String.toString()*
1546 public |java.lang.String| toString()
1548 This object (which is already a string!) is itself returned.
1552 Returns: the string itself.
1554 *java.lang.String.toUpperCase()*
1556 public |java.lang.String| toUpperCase()
1558 Converts all of the characters in this String to upper case using the rules of
1559 the default locale. This method is equivalent to
1560 toUpperCase(Locale.getDefault()).
1562 Note: This method is locale sensitive, and may produce unexpected results if
1563 used for strings that are intended to be interpreted locale independently.
1564 Examples are programming language identifiers, protocol keys, and HTML tags.
1565 For instance, "title".toUpperCase() in a Turkish locale returns "T?TLE", where
1566 '?' is the LATIN CAPITAL LETTER I WITH DOT ABOVE character. To obtain correct
1567 results for locale insensitive strings, use toUpperCase(Locale.ENGLISH).
1571 Returns: the String, converted to uppercase.
1573 *java.lang.String.toUpperCase(Locale)*
1575 public |java.lang.String| toUpperCase(java.util.Locale locale)
1577 Converts all of the characters in this String to upper case using the rules of
1578 the given Locale. Case mapping is based on the Unicode Standard version
1579 specified by the Character(|java.lang.Character|) class. Since case mappings
1580 are not always 1:1 char mappings, the resulting String may be a different
1581 length than the original String.
1583 Examples of locale-sensitive and 1:M case mappings are in the following table.
1587 Language Code of Locale Lower Case Upper Case Description
1589 tr (Turkish) u0069 u0130 small letter i -> capital letter I with dot above
1591 tr (Turkish) u0131 u0049 small letter dotless i -> capital letter I
1593 (all) u00df u0053 u0053 small letter sharp s -> two letters: SS
1595 (all) Fahrvergngen FAHRVERGNGEN
1600 locale - use the case transformation rules for this locale
1602 Returns: the String, converted to uppercase.
1604 *java.lang.String.trim()*
1606 public |java.lang.String| trim()
1608 Returns a copy of the string, with leading and trailing whitespace omitted.
1610 If this String object represents an empty character sequence, or the first and
1611 last characters of character sequence represented by this String object both
1612 have codes greater than 'u0020' (the space character), then a reference to this
1613 String object is returned.
1615 Otherwise, if there is no character with a code greater than 'u0020' in the
1616 string, then a new String object representing an empty string is created and
1619 Otherwise, let k be the index of the first character in the string whose code
1620 is greater than 'u0020', and let m be the index of the last character in the
1621 string whose code is greater than 'u0020'. A new String object is created,
1622 representing the substring of this string that begins with the character at
1623 index k and ends with the character at index m-that is, the result of
1624 this.substring(k,m+1).
1626 This method may be used to trim whitespace (as defined above) from the
1627 beginning and end of a string.
1631 Returns: A copy of this string with leading and trailing white space removed, or this
1632 string if it has no leading or trailing white space.
1634 *java.lang.String.valueOf(boolean)*
1636 public static |java.lang.String| valueOf(boolean b)
1638 Returns the string representation of the boolean argument.
1643 Returns: if the argument is true, a string equal to "true" is returned; otherwise, a
1644 string equal to "false" is returned.
1646 *java.lang.String.valueOf(char)*
1648 public static |java.lang.String| valueOf(char c)
1650 Returns the string representation of the char argument.
1655 Returns: a string of length 1 containing as its single character the argument c.
1657 *java.lang.String.valueOf(char[])*
1659 public static |java.lang.String| valueOf(char[] data)
1661 Returns the string representation of the char array argument. The contents of
1662 the character array are copied; subsequent modification of the character array
1663 does not affect the newly created string.
1666 data - a char array.
1668 Returns: a newly allocated string representing the same sequence of characters contained
1669 in the character array argument.
1671 *java.lang.String.valueOf(char[],int,int)*
1673 public static |java.lang.String| valueOf(
1678 Returns the string representation of a specific subarray of the char array
1681 The offset argument is the index of the first character of the subarray. The
1682 count argument specifies the length of the subarray. The contents of the
1683 subarray are copied; subsequent modification of the character array does not
1684 affect the newly created string.
1687 data - the character array.
1688 offset - the initial offset into the value of the String.
1689 count - the length of the value of the String.
1691 Returns: a string representing the sequence of characters contained in the subarray of
1692 the character array argument.
1694 *java.lang.String.valueOf(double)*
1696 public static |java.lang.String| valueOf(double d)
1698 Returns the string representation of the double argument.
1700 The representation is exactly the one returned by the Double.toString method of
1706 Returns: a string representation of the double argument.
1708 *java.lang.String.valueOf(float)*
1710 public static |java.lang.String| valueOf(float f)
1712 Returns the string representation of the float argument.
1714 The representation is exactly the one returned by the Float.toString method of
1720 Returns: a string representation of the float argument.
1722 *java.lang.String.valueOf(int)*
1724 public static |java.lang.String| valueOf(int i)
1726 Returns the string representation of the int argument.
1728 The representation is exactly the one returned by the Integer.toString method
1734 Returns: a string representation of the int argument.
1736 *java.lang.String.valueOf(long)*
1738 public static |java.lang.String| valueOf(long l)
1740 Returns the string representation of the long argument.
1742 The representation is exactly the one returned by the Long.toString method of
1748 Returns: a string representation of the long argument.
1750 *java.lang.String.valueOf(Object)*
1752 public static |java.lang.String| valueOf(java.lang.Object obj)
1754 Returns the string representation of the Object argument.
1759 Returns: if the argument is null, then a string equal to "null"; otherwise, the value of
1760 obj.toString() is returned.