Home > Java > JavaBase > body text

How to determine whether a character is a number in java

王林
Release: 2019-11-23 11:15:51
Original
3028 people have browsed it

How to determine whether a character is a number in java

In C, you can use isdigit() to determine whether a character is a number, and isalpha() to determine whether a character is a letter. Similar methods in JAVA are mainly It is a static method of the Character class:

The example is as follows:

Character.isDigit( char ch )   // 判断ch是否是数字字符,如'1','2‘,是返回true。
否则返回false
Copy after login
Character.isLowerCase(c) || Character.isUpperCase(c) // 判断ch是否是字母字符,如'a','b‘,是返回true。
否则返回false
Copy after login
Character.isLetterOrDigit( char ch ) // 判断ch是否是字母或数字字符,如'a','b‘,'1','2',是返回true。
否则返回false
Copy after login

Recommended tutorial: java introductory tutorial

The above is the detailed content of How to determine whether a character is a number in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template