怎么在java中判断输入的是字符串还是整数?

2025-12-05 00:03:44
推荐回答(1个)
回答1:

String s = "";
if (s.matches("\\d+")) {
System.out.println("整数");
} else {
System.out.println("非整数");
}