Create a character object from char value

Character is a simple wrapper around a char.

Character(char value)
Creates a Character object for char value.

public class Main{
  public static void main(String[] argv){
    System.out.println(new Character('a'));    
  }
}

The output:


a

Check the character type

static boolean isDefined(char ch)
Returns true if ch is defined by Unicode. Otherwise, it returns false.
static boolean isDigit(char ch)
Returns true if ch is a digit. Otherwise, it returns false.
static boolean isIdentifierIgnorable(char ch)
Returns true if ch should be ignored in an identifier. Otherwise, it returns false.
static boolean isISOControl(char ch)
Returns true if ch is an ISO control character. Otherwise, it returns false.
static boolean isJavaIdentifierPart(char ch)
Returns true if ch is allowed as part of a Java identifier (other than the first character). Otherwise, it returns false.
static boolean isJavaIdentifierStart(char ch)
Returns true if ch is allowed as the first character of a Java identifier. Otherwise, it returns false.
static boolean isLetter(char ch)
Returns true if ch is a letter. Otherwise, it returns false.
static boolean isLetterOrDigit(char ch)
Returns true if ch is a letter or a digit. Otherwise, it returns false.
static boolean isLowerCase(char ch)
Returns true if ch is a lowercase letter. Otherwise, it returns false.
static boolean isMirrored(char ch)
Returns true if ch is a mirrored Unicode character. A mirrored character is one that is reversed for text that is displayed right-to-left.
static boolean isSpaceChar(char ch)
Returns true if ch is a Unicode space character. Otherwise, it returns false.
static boolean isTitleCase(char ch)
Returns true if ch is a Unicode titlecase character. Otherwise, it returns false.
static boolean isUnicodeIdentifierPart(char ch)
Returns true if ch is allowed as part of a Unicode identifier (other than the first character). Otherwise, it returns false.
static boolean isUnicodeIdentifierStart(char ch)
Returns true if ch is allowed as the first character of a Unicode identifier. Otherwise, it returns false.
static boolean isUpperCase(char ch)
Returns true if ch is an uppercase letter. Otherwise, it returns false.
static boolean isWhitespace(char ch)
Returns true if ch is whitespace. Otherwise, it returns false.

Character defines two methods, forDigit( ) and digit( ), that enable you to convert between integer values and the digits they represent. They are shown here:


static char forDigit(int num, int radix) 
static int digit(char digit, int radix)

forDigit( ) returns the digit character associated with the value of num. The radix of the conversion is specified by radix. digit( ) returns the integer value associated with the specified character according to the specified radix. Another method defined by Character is compareTo( ), which has the following form:


static char toLowerCase(char ch) Returns lowercase equivalent of ch. 
static char toTitleCase(char ch) Returns titlecase equivalent of ch. 
static char toUpperCase(char ch) Returns uppercase equivalent of ch.
int compareTo(Character c)

It returns zero if the invoking object and c have the same value. It returns a negative value if the invoking object has a lower value. Otherwise, it returns a positive value.

Home 
  Java Book 
    Essential Classes  

Character:
  1. Create a character object from char value
  2. Get char value from Character object
  3. Check the character type
  4. Get the char type from char value
  5. Change character case
  6. Compare two characters
  7. Convert character to String
  8. Get the numeric value for a char