Share via


String.String

Class Overview | Class Members | This Package | All Packages

Syntax 1

public String()

Description

Allocates a new String containing no characters.

Syntax 2

public String( String value )

Parameters
  • value
    a String.
Description

Allocates a new string that contains the same sequence of characters as the string argument.

Syntax 3

public String( char value[] )

Parameters
  • value
    the initial value of the string.
Description

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

Syntax 4

public String( char value[], int offset**, int** count )

Parameters
  • value
    array that is the source of characters.
  • offset
    the initial offset.
  • count
    the length.
Description

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.

Exceptions

StringIndexOutOfBoundsException if the offset and count arguments index characters outside the bounds of the value array.

Syntax 5

public String( byte ascii[], int hibyte**, int** offset**, int** count )

Parameters
  • ascii
    the bytes to be converted to characters.
  • hibyte
    the top 8 bits of each 16-bit Unicode character.
  • offset
    the initial offset.
  • count
    the length.
Description

**Note: String() is 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 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.

Exceptions

StringIndexOutOfBoundsException if the offset or count argument is invalid.

See Also

String, String, String, String, String

Syntax 6

public String( byte ascii[], int hibyte )

Parameters
  • ascii
    the bytes to be converted to characters.
  • hibyte
    the top 8 bits of each 16-bit Unicode character.
Description

**Note: String() is 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 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:

c == (char)(((hibyte & 0xff) << 8)
                         | (b & 0xff))
 
See Also

String, String, String, String

Syntax 7

public String( byte bytes[], int offset**, int** length**, String** enc ) throws UnsupportedEncodingException

Parameters
  • bytes
    The bytes to be converted into characters
  • offset
    Index of the first byte to convert
  • length
    Number of bytes to convert
  • enc
    The name of a character encoding
Description

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.

Exceptions

UnsupportedEncodingException If the named encoding is not supported

Syntax 8

public String( byte bytes[], String enc ) throws UnsupportedEncodingException

Parameters
  • bytes
    The bytes to be converted into characters
  • enc
    A character-encoding name
Description

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.

Exceptions

UnsupportedEncodingException If the named encoding is not supported

Syntax 9

public String( byte bytes[], int offset**, int** length )

Parameters
  • bytes
    The bytes to be converted into characters
  • offset
    Index of the first byte to convert
  • length
    Number of bytes to convert
Description

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.

Syntax 10

public String( byte bytes[] )

Parameters
  • bytes
    The bytes to be converted into characters
Description

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.

Syntax 11

public String( StringBuffer buffer )

Parameters
  • buffer
    a StringBuffer.
Description

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