Package java.lang Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class Character

Fields , Constructors , Methods , Footnotes

public  final  class  java.lang.Character
    extends  java.lang.Object  
{
        // Fields
    public final static int MAX_RADIX;	
    public final static char MAX_VALUE;	
    public final static int MIN_RADIX;	
    public final static char MIN_VALUE;	

        // Constructors
    public Character(char  value);	

        // Methods
    public char charValue();	
    public static int digit(char  ch, int  radix);	
    public boolean equals(Object  obj);	
    public static char forDigit(int  digit, int  radix);	
    public int hashCode();	
    public static boolean isDefined(char  ch);	
    public static boolean isDigit(char  ch);	
    public static boolean isJavaLetter(char  ch);	
    public static boolean isJavaLetterOrDigit(char  ch);	
    public static boolean isLetter(char  ch);	
    public static boolean isLetterOrDigit(char  ch);	
    public static boolean isLowerCase(char  ch);	
    public static boolean isSpace(char  ch);	
    public static boolean isTitleCase(char  ch);	
    public static boolean isUpperCase(char  ch);	
    public static char toLowerCase(char  ch);	
    public String toString();	
    public static char toTitleCase(char  ch);	
    public static char toUpperCase(char  ch);	
}

This class wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char.

In addition, this class provides a number of methods for determining the type of a character, and converting characters from uppercase to lowercase and vice versa.

Many of the methods of class Character are defined in terms of a "Unicode attribute table" that specifies a name for every defined Unicode code point. The table also includes other attributes, such as a decimal value, an uppercase equivalent, a lowercase equivalent, and/or a titlecase equivalent. The Unicode attribute table is available on the World Wide Web as the file

ftp://unicode.org/pub/MappingTables/UnicodeData1.1.5.txt


Fields


MAX_RADIX

public final static int MAX_RADIX = 36 

The constant value of this field is the largest value permitted for the radix argument in radix-conversion methods such as the digit method, the forDigit method, and the toString method of class Integer.


MAX_VALUE(1)

public final static char MAX_VALUE = '\uffff' 

The constant value of this field is the largest value of type char.


MIN_RADIX

public final static int MIN_RADIX = 2 

The constant value of this field is the smallest value permitted for the radix argument in radix-conversion methods such as the digit method, the forDigit method, and the toString method of class Integer.


MIN_VALUE(2)

public final static char MIN_VALUE = '\u0000' 

The constant value of this field is the smallest value of type char.


Constructors


Character

public Character(char  value) 

Constructs a Character object and initializes it so that it represents the primitive value argument.

ParameterDescription
value value for the new Character object


Methods


charValue

public char charValue() 

Return Value:

Returns The primitive char value represented by this object.


digit

public static int digit(char  ch, int  radix) 

Returns the numeric value of the character ch in the specified radix.

If the radix is not in the range MIN_RADIX £ radix £ MAX_RADIX or if the ch is not a valid digit in the specified radix, -1 is returned. A character is a valid digit if either of the following is true:

Return Value:

Returns the numeric value represented by the character in the specified radix.

ParameterDescription
ch the character to be converted
radix the radix

See Also: forDigit .


equals

public boolean equals(Object  obj) 

The result is true if and only if the argument is not null and is a Character object that represents the same char value as this object.

Return Value:

Returns true if the objects are the same; false otherwise.

ParameterDescription
obj the object to compare with

Overrides:

equals in class Object .


forDigit

public static char forDigit(int  digit, int  radix) 

Determines the character representation for a specific digit in the specified radix. If the value of radix is not a valid radix, or the value of digit is not a valid digit in the specified radix, the null character ('\u0000') is returned.

The radix argument is valid if it is greater than or equal to MIN_RADIX and less than or equal to MAX_RADIX . The digit argument is valid if 0 £ digit < radix.

If the digit is less than 10, then '0' + digit is returned. Otherwise, the value 'a' + digit - 10 is returned.

Return Value:

Returns the char representation of the specified digit in the specified radix.

ParameterDescription
digit the number to convert to a character
radix the radix.

See Also: digit .


hashCode

public int hashCode() 

Return Value:

Returns a hash code value for this object.

Overrides:

hashCode in class Object .


isDefined(3)

public static boolean isDefined(char  ch) 

Determines if a character has a defined meaning in Unicode. A character is defined if at least one of the following is true:

Return Value:

Returns true if the character has a defined meaning in Unicode; false otherwise.

ParameterDescription
ch the character to be tested


isDigit(4)

public static boolean isDigit(char  ch) 

Determines whether the specified character is a digit. A character is considered to be a digit if it is not in the range '\u2000' through '\uu2000' and its Unicode name contains the word "DIGIT".

Return Value:

Returns true if the character is a digit; false otherwise.

ParameterDescription
ch the character to be tested


isJavaLetter(5)

public static boolean isJavaLetter(char  ch) 

Determines whether the specified character is a "Java" letter, that is, the character is permissible as the first character in an identifier in the Java language..

A character is considered to be a Java letter if and only if it is a letter, the ASCII dollar sign character '$', or the underscore character '_'.

Return Value:

Returns true if the character is a Java letter; false otherwise.

ParameterDescription
ch the character to be tested

See Also: isLetter isLetterOrDigit isJavaLetterOrDigit .


isJavaLetterOrDigit(6)

public static boolean isJavaLetterOrDigit(char  ch) 

Determines whether the specified character is a "Java" letter or digit, that is, the character is permissible as a non-initial character in an identifier in the Java language..

A character is considered to be a Java letter or digit if and only if it is a letter, a digit, the ASCII dollar sign character '$', or the underscore character '_'.

Return Value:

Returns true if the character is a Java letter or digit; false otherwise.

ParameterDescription
ch the character to be tested

See Also: isLetter isLetterOrDigit isJavaLetter .


isLetter

public static boolean isLetter(char  ch) 

Determines whether the specified character is a letter.

Return Value:

Returns true if the character is a letter; false otherwise.

ParameterDescription
ch the character to be tested

See Also: isJavaLetter isJavaLetterOrDigit .


isLetterOrDigit(7)

public static boolean isLetterOrDigit(char  ch) 

Return Value:

Returns true if the character is a letter or digit; false otherwise.

ParameterDescription
ch the character to be tested

See Also: isDigit isLetter isJavaLetter isJavaLetterOrDigit .


isLowerCase(8)

public static boolean isLowerCase(char  ch) 

Determines whether the specified character is a lowercase character.

A character is lowercase if it is not in the range '\u2000' through '\u2FFF', the Unicode attribute table does not specify a mapping to lowercase for the character, and at least one of the following is true:

Return Value:

Returns true if the character is lowercase; false otherwise.

ParameterDescription
ch the character to be tested

See Also: isUpperCase isTitleCase toLowerCase .


isSpace

public static boolean isSpace(char  ch) 

Determines if a character is white space.

This method returns true for the following five characters only:

'\t'	\u0009	HORIZONTAL TABULATION
'\n'	\u000A		NEW LINE
'\f'	\u000C		FORM FEED
'\r'	\u000D		CARRIAGE RETURN
' '	\u0020		SPACE 

Return Value:

Returns true if the character is ISO-LATIN-1 white space; false otherwise.

ParameterDescription
ch the character to be tested


isTitleCase(9)

public static boolean isTitleCase(char  ch) 

Determines if the character is a titlecase character.

There are four Unicode characters whose printed representations look like pairs of Latin letters. For example, there is an uppercase letter that looks like "LJ" and the corresponding lowercase letter looks like "lj". A third form, which looks like "Lj" that is the appropriate form to use when rendering a word in lowercase with initial capitals, as for a book title.

These are the Unicode characters for which this method returns true:

Return Value:

Returns true if the character is titlecase; false otherwise.

ParameterDescription
ch the character to be tested

See Also: isUpperCase isLowerCase toTitleCase .


isUpperCase(10)

public static boolean isUpperCase(char  ch) 

Determines whether the specified character is an uppercase character.

A character is uppercase if it is not in the range '\u2000' through '\u2FFF', the Unicode attribute table does not specify a mapping to uppercase for the character, and at least one of the following is true:

Return Value:

Returns true if the character is uppercase; false otherwise.

ParameterDescription
ch the character to be tested

See Also: isLowerCase isTitleCase toUpperCase .


toLowerCase(11)

public static char toLowerCase(char  ch) 

The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned.

A character has a lowercase equivalent if and only if a lowercase mapping is specified for the character in the Unicode attribute table.

Note that some Unicode characters in the range '\u2000' through '\u2FFF' have lowercase mappings; this method does map such characters to their lowercase equivalents even though the method isUpperCase does not return true for such characters.

Return Value:

Returns the lowercase equivalent of the character, if any; otherwise the character itself.

ParameterDescription
ch the character to be converted

See Also: isLowerCase .


toString

public String toString() 

Converts this Character object to a string. The result is a string whose length is 1 and whose sole component is the primitive char value represented by this object.

Return Value:

Returns a string representation of this object.

Overrides:

toString in class Object .


toTitleCase(12)

public static char toTitleCase(char  ch) 

Converts the character argument to titlecase. A character has a titlecase equivalent if and only if a titlecase mapping is specified for the character in the Unicode attribute table.

Note that some Unicode characters in the range '\u2000' through '\u2FFF' have titlecase mappings; this method does map such characters to their titlecase equivalents even though the method isTitleCase does not return true for such characters.

Return Value:

Returns the titlecase equivalent of the character, if any; otherwise the character itself.

ParameterDescription
ch the character to be converted

See Also: isTitleCase .


toUpperCase(13)

public static char toUpperCase(char  ch) 

Converts the character argument to uppercase. A character has an uppercase equivalent if and only if a titlecase mapping is specified for the character in the Unicode attribute table.

Note that some Unicode characters in the range '\u2000' through '\u2000FFF' have uppercase mappings; this method does map such characters to their titlecase equivalents even though the method isLowerCase does not return true for such characters.

Return Value:

Returns the uppercase equivalent of the character, if any; otherwise the character itself.

ParameterDescription
ch the character to be converted

See Also: isUpperCase .


Footnotes

(1)This field is new in Java 1.1.

(2)This field is new in Java 1.1.

(3)This method is new in Java 1.1.

(4)In Version 1.0, this version returns true only for the ten ASCII digits `0' through '9'.

(5)This method is new in Java 1.1

(6)This method is new in Java 1.1

(7)This method is new in Java 1.1

(8)In Version 1.0, this version returns true only for lowercase characters in the range '\u0000' to '\u00FF'.

(9)This method is new in Java 1.1.

(10)In Java 1.0, this method returns true only for uppercase characters in the range '\u0000' to '\u00FF'.

(11)In Java 1.0, this method only works on characters in the range '\u0000' to '\u00FF'. For characters outisde this range, the method returns its argument unchanged.

(12)This method is new in Java 1.1

(13)In Java 1.0, this method only works on characters in the range '\u0000' to '\u00FF'. For characters outside this range, the method returns its argument unchanged.

Top© 1996 Sun Microsystems, Inc. All rights reserved.