首页javacharJava Data Type - 如何检查字符是字母还是数字

Java Data Type - 如何检查字符是字母还是数字

我们想知道如何检查字符是字母还是数字。

isDigit(): true if the argument is a digit (0 to 9), and false otherwise.

public class MainClass { public static void main(String[] args) { char symbol = 'A'; if (Character.isDigit(symbol)) { System.out.println("true"); }else{ System.out.println("false"); } } }