Computer Applications
How can you check if a given character is a digit, a letter or a space?
Java Library Classes
2 Likes
Answer
We can check if a given character is a digit, a letter or a space by using the following methods of Character class:
isDigit(char) — It returns true if the specified character is a digit; returns false otherwise.
Syntax:boolean isDigit(char ch)isLetter(char) — It returns true if the specified character is a letter; returns false otherwise.
Syntax:boolean isLetter(char ch)isLetterOrDigit(char) — It returns true if the specified character is a letter or a digit; returns false otherwise.
Syntax:boolean isLetterOrDigit(char ch)isWhitespace(char) — It returns true if the specified character is whitespace; returns false otherwise.
Syntax:boolean isWhitespace(char ch)
Answered By
3 Likes