java用ascii码判断输入的是大写字母,小写字母还是数字
关注:229 答案:1 mip版
解决时间 2021-02-05 13:27
提问者阳光在浪尖跳动
2021-02-05 04:14
用ascii码判断,老师还没有交String[] args这类定义,直接让做。网上看了很多,感觉看不懂意思。连哪里输入都看不出来。例如:
import java.util.Scanner;
public static void main(String[] args) {
Scanner scanner = new
Scanner(System.in);
String str = scanner.nextLine().trim();
if
(str.length() > 1) {
System.out.println("输入字符串");
} else if
(str.matches("[a-z]")) {
System.out.println("输入写字母");
} else if
(str.matches("[A-Z]")) {
System.out.println("输入写字母");
} else if<