题解 | #判断是不是字母#
判断是不是字母
http://www.nowcoder.com/practice/91a588dd4cd244bfa616f17603ec123c
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(scan.hasNextLine()) {
String str = scan.nextLine();
if(str.matches("[a-zA-Z]")) {//正则匹配yyds!
System.out.println(str + " is an alphabet.");
} else {
System.out.println(str + " is not an alphabet.");
}
}
}
}