Javatpoint Logo
Javatpoint Logo

Java Character isLetterOrDigit() Method

The isLetterOrDigit(char ch) method of character class determines whether the given(or specified) character is a letter or digit or not.

A character is considered to be a letter or digit if the Character.isLetter(char ch) or the Character.isDigit(char ch) method true for the given character.

Note: The above method cannot be used to handle the supplementary characters. In order to handle the supplementary characters, we can use the isLetterOrDigit(int) method.

Syntax

Parameter

The above method requires only one parameter:

a.)The character that needs to be tested.

Return Value

The isLetterOrDigit(char ch) method returns a boolean value i.e. true, if the given(or specified) character is a letter or digit. Otherwise, the method returns false.

Example 1

Test it Now

Output:

The first character 'A' is a letter or digit: true
The second character '1' is a letter or digit: true
The third character 'U' is a letter or digit: true
The fourth character '2' is a letter or digit: true

Example 2

Test it Now

Output:

The first character 'A' is a letter or digit: true
The second character '1' is a letter or digit: true
The third character '*' is a letter or digit: false
The fourth character '$' is a letter or digit: false

Example 3

Output:

Enter the first input:R
The character 'R' is a letter or digit. 
Enter the second input:9
The character '9' is a letter or digit. 
Enter the third input:A
The character 'A' is a letter or digit.

Java Character isLetterOrDigit() Method

The isLetterOrDigit(int codePoint) method of Character class determines whether the given(or specified) character is a letter or digit Sor not.

A character is considered to be a letter or digit if the Character.isLetter(int codePoint) or the Character.isDigit(int codePoint) method returns true for the given character.

Syntax

Parameter

codePoint: It is the codePoint which is the character that needs to be tested.

Return Value

The isLetter(int codePoint)method returns a Boolean value i.e. true if the given(or specified) character is a letter or digit. Otherwise, the method returns false.

Example 4

Test it Now

Output:

The first codePoint  '26' is a letter or a  digit: false
The second codePoint '134' is a letter or a  digit: false
The third codePoint  '198' is a letter or a  digit: true
The fourth codePoint '408' is a letter or a digit: true

Example 5

Output:

Enter the first input:A
The character 'A' is a letter or digit. 
Enter the second input:6
The character '6' is a letter or digit. 
Enter the third input:^
The character '^' is a letter or digit.. 
Next TopicJava Character




Please Share

facebook twitter google plus pinterest