📌  相关文章
📜  如何在java代码示例中检查字符串是否仅包含字母和空格

📅  最后修改于: 2022-03-11 14:52:05.360000             🧑  作者: Mango

代码示例2
class IsAlpha
{
    public static boolean isAlpha(String s) {
        return s != null && s.matches("^[a-zA-Z]*$");
    }
 
    public static void main(String[] args)
    {
        String s = "ABCD";
        System.out.println("IsAlpha: " + isAlpha(s));
    }
}