Character Class (Cont.)


Java compiler will create a Character object under some circumstances. For example, if a primitive char is passed into a method that expects an object, the char is automatically converted to a Character. This feature is called autoboxing or unboxing, if the conversion goes the other way.

 // The primitive char 'a' is boxed into the Character object ch.
 Character ch = 'a';

 // 'x' is boxed for method test whose return is unboxed to char 'c'.
 char c = test('x');

Escape Sequences
A character preceded by a backslash (\) is an escape sequence:

Escape sequence Description
\t Inserts a tab in the text at this point.
\b Inserts a backspace in the text at this point.
\n Inserts a newline in the text at this point.
\r Inserts a carriage return in the text at this point.
\f Inserts a form feed in the text at this point.
\' Inserts a single quote character in the text at this point.
\" Inserts a double quote character in the text at this point.
\\ Inserts a backslash character in the text at this point.

Character Methods
Instance methods that all the subclasses of the Character class implement:

Method Description
isLetter( )

Determines whether the specified char value is a letter.

isDigit()

Determines whether the specified char value is a digit.

isWhitespace( )

Determines whether the specified char value is white space.

isUpperCase( )

Determines whether the specified char value is uppercase.

isLowerCase( )

Determines whether the specified char value is lowercase.

toUpperCase( )

Returns the uppercase form of the specified char value.

toLowerCase( )

Returns the lowercase form of the specified char value.

toString( )

Returns a String object representing the specified character value that is, a one-character string.





      “Let no man pull you so low as to hate him.”    
      ― Martin Luther King Jr., A Knock at Midnight