This Java Tutorial is all about Characters.
Most of the time when we work with single character value we use primitive type char.
However ,sometimes we need to use a char as an object.For this purpose Java provides us wrapper class that wraps char to Character object.A Character object can be created with a Character constructor.
Character c = new Character(‘Z’);
Value of char variable ch1 is :z
Value of char variable ch2 is :Z
Under some circumstances,Java compiler creates a Character object.For example, if we pass a primitive char into a method that expects an object, the compiler automatically converts the char to a Character. This feature is called autoboxing.If the conversion goes the other way ,it is called unboxing.
s.no. Methods Description
1. isLetter() Checks whether the given char value is a letter.
2. isDigit() Checks whether the given char value is a digit.
3. isWhitespace() Checks whether the given char value is white space.
4. isUpperCase() Checks whether the given char value is in upper case.
5. isLowerCase() Checks whether the given char value is in lower case.
6. toUpperCase() Returns upper case of the specified char value.
7. toLowerCase() Returns the lower case of the specified char value.
These are the characters preceded by a backslash(\) and have a special meaning to a compiler.
Escape Sequence Description
\f form feed
\” ” (double quote)
\’ ‘ (single quote)
\\ \ (back slash)
\uDDDD character from the Unicode character set (DDDD is four hex digits)