Java Character isLetterOrDigit() MethodThe 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.SyntaxParameterThe above method requires only one parameter: a.)The character that needs to be tested. Return ValueThe 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 1Test it NowOutput: 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 2Test it NowOutput: 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 3Output: 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() MethodThe 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. SyntaxParametercodePoint: It is the codePoint which is the character that needs to be tested. Return ValueThe 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 4Test it NowOutput: 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 5Output: 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
|