Java Character Methods
All Character Methods
The Character class is the wrapper class for the char type. It has a set of methods that test and change single characters.
All the methods in the table are static (they belong to the class), so you call them on the class name, for example Character.isDigit('7'). Use them when you work with text one character at a time, for example to count the letters or digits in a string.
| Method | Description | Return Type |
|---|---|---|
| compare() | Compares two characters and returns a number that shows which one comes first | int |
| getNumericValue() | Returns the number that a character stands for, like 7 for the character '7' | int |
| isAlphabetic() | Checks if a character is alphabetic (a letter, or a character that works like a letter) | boolean |
| isDigit() | Checks if a character is a digit, like '0' to '9' | boolean |
| isLetter() | Checks if a character is a letter | boolean |
| isLetterOrDigit() | Checks if a character is a letter or a digit | boolean |
| isLowerCase() | Checks if a character is a lowercase letter | boolean |
| isUpperCase() | Checks if a character is an uppercase letter | boolean |
| isWhitespace() | Checks if a character is whitespace, like a space, a tab or a new line | boolean |
| toLowerCase() | Converts a character to lowercase | char|int |
| toString() | Converts a character to a String | String |
| toUpperCase() | Converts a character to uppercase | char|int |
| valueOf() | Returns a Character object that holds the given char value | Character |