FileDocCategorySizeDatePackage
Character.javaAPI DocphoneME MR2 API (J2ME)8329Wed May 02 17:59:54 BST 2007java.lang

Character

public final class Character extends Object
The Character 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 several methods for determining the type of a character and converting characters from uppercase to lowercase and vice versa.

version
1.60, 12/04/99 (CLDC 1.0, Spring 2000)
since
JDK1.0

Fields Summary
public static final int
MIN_RADIX
The minimum radix available for conversion to and from Strings.
public static final int
MAX_RADIX
The maximum radix available for conversion to and from Strings.
public static final char
MIN_VALUE
The constant value of this field is the smallest value of type char.
public static final char
MAX_VALUE
The constant value of this field is the largest value of type char.
private char
value
The value of the Character.
static DefaultCaseConverter
cc
Constructors Summary
public Character(char value)
Constructs a Character object and initializes it so that it represents the primitive value argument.

param
value value for the new Character object.


                                   
       
        this.value = value;
    
Methods Summary
static DefaultCaseConvertercaseConverter()


        if (cc != null) {
           return cc;
        }

        String ccName = "?";

        try {
            /* Get the default encoding name */
            ccName = System.getProperty("java.lang.Character.caseConverter");
            if (ccName == null) {
                ccName = "com.sun.cldc.i18n.uclc.DefaultCaseConverter";
            }

            /* Using the decoder names lookup a class to implement the reader */
            Class clazz = Class.forName(ccName);

            /* Return a new instance */
            cc = (DefaultCaseConverter)clazz.newInstance();

        } catch(Exception x) {
            throw new RuntimeException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped                       "Cannot find case converter class "+ccName+" -> "+x.getMessage()
/* #endif */
            );
        }

        return cc;
    
public charcharValue()
Returns the value of this Character object.

return
the primitive char value represented by this object.

        return value;
    
public static intdigit(char ch, int radix)
Returns the numeric value of the character ch in the specified radix.

param
ch the character to be converted.
param
radix the radix.
return
the numeric value represented by the character in the specified radix.
see
java.lang.Character#isDigit(char)
since
JDK1.0

        return caseConverter().digit(ch, radix);
    
public booleanequals(java.lang.Object obj)
Compares this object against the specified object. 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.

param
obj the object to compare with.
return
true if the objects are the same; false otherwise.

        if (obj instanceof Character) {
            return value == ((Character)obj).charValue();
        }
        return false;
    
public inthashCode()
Returns a hash code for this Character.

return
a hash code value for this object.

        return (int)value;
    
public static booleanisDigit(char ch)
Determines if the specified character is a digit.

param
ch the character to be tested.
return
true if the character is a digit; false otherwise.
since
JDK1.0

        return caseConverter().isDigit(ch);
    
public static booleanisLowerCase(char ch)
Determines if the specified character is a lowercase character.

param
ch the character to be tested.
return
true if the character is lowercase; false otherwise.
since
JDK1.0

        return caseConverter().isLowerCase(ch);
    
public static booleanisUpperCase(char ch)
Determines if the specified character is an uppercase character.

param
ch the character to be tested.
return
true if the character is uppercase; false otherwise.
see
java.lang.Character#isLowerCase(char)
see
java.lang.Character#toUpperCase(char)
since
1.0

        return caseConverter().isUpperCase(ch);
    
public static chartoLowerCase(char ch)
The given character is mapped to its lowercase equivalent; if the character has no lowercase equivalent, the character itself is returned.

param
ch the character to be converted.
return
the lowercase equivalent of the character, if any; otherwise the character itself.
see
java.lang.Character#isLowerCase(char)
see
java.lang.Character#isUpperCase(char)
see
java.lang.Character#toUpperCase(char)
since
JDK1.0

        return caseConverter().toLowerCase(ch);
    
public java.lang.StringtoString()
Returns a String object representing this character's value. Converts this Character object to a string. The result is a string whose length is 1. The string's sole component is the primitive char value represented by this object.

return
a string representation of this object.

        char buf[] = {value};
        return String.valueOf(buf);
    
public static chartoUpperCase(char ch)
Converts the character argument to uppercase; if the character has no lowercase equivalent, the character itself is returned.

param
ch the character to be converted.
return
the uppercase equivalent of the character, if any; otherwise the character itself.
see
java.lang.Character#isLowerCase(char)
see
java.lang.Character#isUpperCase(char)
see
java.lang.Character#toLowerCase(char)
since
JDK1.0

        return caseConverter().toUpperCase(ch);