Java Character isDigit() MethodThe isDigit(int codePoint) method of Character class generally determines whether the given character is a digit or not. Generally, a character is considered as a digit if its general category given by getType(codePoint), is DECIMAL_DIGIT_NUMBER. SyntaxParameterThe above method requires only one parameter: a.)The codePoint which is a Unicode character that needs to be tested. Return ValueThe isDigit(int codePoint) method returns a boolean value i.e. true, if the given(or specified) character is a digit. Otherwise, the method returns false. Example 1Output: The codePoint '55' is a digit. The codePoint '32' is not a digit. The codePoint '121' is not a digit. The codePoint '49' is a digit. The codePoint '200' is not a digit. Example 2Output: The first object represents a digit : true The first object represents a digit : false The first object represents a digit : false The first object represents a digit : false Java Character isDigit() MethodThe isDigit(char ch) method of Character class generally determines whether the given character is a digit or not. Generally, a character is considered as a digit if its general category given by Character.getType(ch), is DECIMAL_DIGIT_NUMBER. Note: The above method cannot be used to handle the supplementary characters. In order to support all the Unicode characters, including all the supplementary characters, we can use the isdigit(int) method.SyntaxParameterThe above method requires only one parameter a.)The character that needs to be tested.Return ValueThe isDigit(char ch) method returns a boolean value, i.e., true if the given(or specified) character is a digit. Otherwise, the method returns false. Example 3Output: The digit ' ' is:false The digit '4' is:true The digit '8' is:true Example 4Output: Enter the first character: & The character '&' is not a digit. Enter the first character: 3 The character '3' is a digit. Example 5Output: The digit 'A' is:false The digit '3' is:true The digit 'b' is:false The digit '6' is:true Next TopicJava-character-ishighsurrogate-method |