Java provides a wrapper class that "wraps" the
char
in a Character
object for this purpose. An object of type Character
contains a single field, whose type is char
. char ch = 'a'; // Unicode for uppercase Greek omega character char uniChar = '\u03A9'; // an array of chars char[] charArray = { 'a', 'b', 'c', 'd', 'e' };
Note: The
Character
class is immutable, so that once it is created, a Character
object cannot be changed.Character ch = new Character('a');
Method | Description |
---|---|
boolean isLetter(char ch) | Determines whether the specified char value is a letter or a digit, respectively. |
boolean isWhitespace(char ch) | Determines whether the specified char value is white space. |
boolean isUpperCase(char ch) | Determines whether the specified char value is uppercase or lowercase, respectively. |
char toUpperCase(char ch) | Returns the uppercase or lowercase form of the specified char value. |
toString(char ch) | Returns a String object representing the specified character value — that is, a one-character string. |
Escape Sequence | Description |
---|---|
\t | Insert a tab in the text at this point. |
\b | Insert a backspace in the text at this point. |
\n | Insert a newline in the text at this point. |
\r | Insert a carriage return in the text at this point. |
\f | Insert a formfeed in the text at this point. |
\' | Insert a single quote character in the text at this point. |
\" | Insert a double quote character in the text at this point. |
\\ | Insert a backslash character in the text at this point. |
No comments:
Post a Comment