题解 | #判断是不是字母#

判断是不是字母

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.");
            }
        }
    }
}
全部评论

相关推荐

01-15 13:52
已编辑
河南大学 Java
六年要多久:标准头像,不吃香菜😂
点赞 评论 收藏
分享
EEbond:给北邮✌️跪了
点赞 评论 收藏
分享
评论
6
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务