String
- class java.lang..
String public final class
String extends
Object implements
Serializable ,
Comparable Tree:java.lang.Object -
java.lang.String The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class.
- Constructor for class java.lang.
String public
String ()
Initializes a newly created String object so that it represents an empty character sequence.
- Constructor for class java.lang.
String public
String (
String  value)
Initializes a newly created String object so that it represents the same sequence of characters as the argument; in other words, the newly created string is a copy of the argument string.
Parameters: value - a String.
- Constructor for class java.lang.
String public
String (
StringBuffer  buffer)
Allocates a new string that contains the sequence of characters currently contained in the string buffer argument. The contents of the string buffer are copied; subsequent modification of the string buffer does not affect the newly created string.
Parameters: buffer - a StringBuffer.
Throws: NullPointerException - If buffer is null.
- Constructor for class java.lang.
String public
String (byte[]Â bytes)
Construct a new String by converting the specified array of bytes using the platform's default character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the byte array.
Parameters: bytes - The bytes to be converted into characters
Since: JDK1.1
- Constructor for class java.lang.
String public
String (byte[]Â bytes,
String  enc) throws
UnsupportedEncodingException Construct a new String by converting the specified array of bytes using the specified character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the byte array.
Parameters: bytes - The bytes to be converted into characters - A character-encoding nameenc - A character-encoding name
Throws: UnsupportedEncodingException - If the named encoding is not supported
Since: JDK1.1
- Constructor for class java.lang.
String public
String (byte[] ascii, int hibyte)
Deprecated. Â
This method does not properly convert bytes into characters. As of JDKÂ 1.1, the preferred way to do this is via the String constructors that take a character-encoding name or that use the platform's default encoding.Allocates a new containing characters constructed from an array of 8-bit integer values. Each character in the resulting string is constructed from the corresponding component in the byte array such that: Allocates a new String containing characters constructed from an array of 8-bit integer values. Each character
cin the resulting string is constructed from the corresponding component
b in the byte array such that:
Parameters: ascii - the bytes to be converted to characters. - the top 8 bits of each 16-bit Unicode character.hibyte - the top 8 bits of each 16-bit Unicode character.
Throws: NullPointerException - If ascii is null.
See Also: String(byte[], int, int, java.lang.String) ,
String(byte[], int, int) ,
String(byte[], java.lang.String) ,
String(byte[])
- Constructor for class java.lang.
String public
String (byte[] bytes, int offset, int length)
Construct a new String by converting the specified subarray of bytes using the platform's default character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the subarray.
Parameters: bytes - The bytes to be converted into characters - Index of the first byte to convertoffset - Index of the first byte to convert - Number of bytes to convertlength - Number of bytes to convert
Since: JDK1.1
- Constructor for class java.lang.
String public
String (byte[] bytes, int offset, int length,
String  enc) throws
UnsupportedEncodingException Construct a new String by converting the specified subarray of bytes using the specified character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the subarray.
Parameters: bytes - The bytes to be converted into characters - Index of the first byte to convertoffset - Index of the first byte to convert - Number of bytes to convertlength - Number of bytes to convert - The name of a character encodingenc - The name of a character encoding
Throws: UnsupportedEncodingException - If the named encoding is not supported IndexOutOfBoundsException if the offset and count arguments index characters outside the bounds of the value array.
Since: JDK1.1
- Constructor for class java.lang.
String public
String (byte[] ascii, int hibyte, int offset, int count)
Deprecated. Â
This method does not properly convert bytes into characters. As of JDKÂ 1.1, the preferred way to do this is via the String constructors that take a character-encoding name or that use the platform's default encoding.Allocates a new constructed from a subarray of an array of 8-bit integer values. Allocates a new String constructed from a subarray of an array of 8-bit integer values. The offset argument is the index of the first byte of the subarray, and the count argument specifies the length of the subarray. Each byte in the subarray is converted to a char as specified in the method above.
Parameters: ascii - the bytes to be converted to characters. - the top 8 bits of each 16-bit Unicode character.hibyte - the top 8 bits of each 16-bit Unicode character. - the initial offset.offset - the initial offset. - the length.count - the length.
Throws: IndexOutOfBoundsException - if the offset or count argument is invalid. - if is .
NullPointerException - if ascii is null.
See Also: String(byte[], int) ,
String(byte[], int, int, java.lang.String) ,
String(byte[], int, int) ,
String(byte[], java.lang.String) ,
String(byte[])
- Constructor for class java.lang.
String public
String (char[]Â value)
Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the newly created string.
Parameters: value - the initial value of the string.
Throws: NullPointerException - if value is null.
- Constructor for class java.lang.
String public
String (char[] value, int offset, int count)
Allocates a new String that contains characters from a subarray of the character array argument. The offset argument is the index of the first character of the subarray and the count argument specifies the length of the subarray. The contents of the subarray are copied; subsequent modification of the character array does not affect the newly created string.
Parameters: value - array that is the source of characters. - the initial offset.offset - the initial offset. - the length.count - the length.
Throws: IndexOutOfBoundsException - if the offset and count arguments index characters outside the bounds of the value array. - if is .
NullPointerException - if value is null.
A data type consisting of a sequence of contiguous characters that represent the characters themselves rather than their numeric values. A String can include letters, numbers, spaces, and punctuation. The String data type can store fixed-length strings ranging in length from 0 to approximately 63K characters and dynamic strings ranging in length from 0 to approximately 2 billion characters. The dollar sign ($) type-declaration character represents a String in Visual Basic.
A sequence of characters (letters, numbers, punctuation marks etc.).
A set of contiguous bytes that contain a single character-based or binary data value. In character strings, each byte, or pair of bytes, represents a single alphabetic letter, special character, or number. In binary strings, the entire value is considered to be a single stream of bits that do not have any inherent pattern. For example, the constant 'I am 32.' is an 8 byte character string, while the constant 0x0205efa3 is a 4 byte binary string.