Page 333 - CA_Blue( J )_Class10
P. 333

•  Character.isDigit(): This method is used to check whether the parameter passed is a digit or not. It returns a
                    boolean value. Syntax of the isDigit() method is:
                    boolean variable=Character.isDigit(char);
                    For example:

                    boolean b= Character.isDigit ('7');
                    Output: true                            // as'7' is a digit
                    boolean b= Character.isDigit ('A');
                    Output: false                           // as'A' is not a digit
                 •  Character.isLetterOrDigit(): This method is used to check whether the parameter passed is a character/digit or
                    not. It returns a boolean value. Syntax of the isLetterOrDigit() method is:
                    boolean variable = Character.isLetterOrDigit (char);
                    For example:

                    boolean b = Character.isLetterOrDigit ('A');
                    Output: true                            // as'A' is a character
                    boolean b = Character.isLetterOrDigit ('1');
                    Output: true                            // as'1' is a digit
                    boolean b = Character.isLetterOrDigit (':');
                    Output: false                    //as':' is not a letter or digit
                 •  Character.isWhitespace(): This method is used to check whether the parameter passed is a space or not. It returns
                    a boolean value. Syntax of the isWhitespace() method is:

                    boolean variable = Character.isWhitespace(char);
                    For example:
                    boolean b = Character.isWhitespace('');
                    Output: true                            // as'' is a whitespace

                    boolean b = Character.isWhitespace('A');
                    Output: false                           // as'' is not a space
                 •  Character.isUpperCase(): This method is used to check whether the parameter passed is an uppercase character
                    or not. It returns a boolean value. Syntax of the isUpperCase() method is:

                    boolean variable = Character.isUpperCase(char);
                    For example:
                    boolean b = Character.isUpperCase('A');
                    Output: true                            // as'A' is an uppercase letter

                    boolean b = Character.isUpperCase('a');
                    Output: false                           // as'a' is not an uppercase letter
                 •  Character.isLowerCase(): This method is used to check whether the parameter passed is a lowercase character or
                    not. It returns a boolean value. Syntax of the isLowerCase() method is:
                    boolean variable = Character.isLowerCase(char);
                    For example:
                    boolean b = Character.isLowerCase('a');
                    Output: true                            // as'a' is a lowercase letter

                    boolean b = Character.isLowerCase('A');
                    Output: false                           // as'A' is not a lowercase letter
                 •  Character.toUpperCase(): This method is used to convert the parameter passed to uppercase letter. It returns a
                    boolean value. Syntax of the toUpperCase() method is:
                    char variable = Character.toUpperCase(char);
                    For example:
                    char b = Character.toUpperCase('A');
                    Output: A

                    char b = Character.toUpperCase('a');
                    Output: A

                                                                                                                       331
                                                                                                        Library Classes    331
   328   329   330   331   332   333   334   335   336   337   338