专业的JAVA编程教程与资源

网站首页 > java教程 正文

使用hutool工具判断字符串是否全部是字母(包括大小写),

temp10 2024-10-16 15:52:54 java教程 14 ℃ 0 评论

使用hutool工具判断字符串是否全部是字母(包括大小写),java判断字符串是否全部是字母(包括大小写)

1.导入hutool的maven依赖

使用hutool工具判断字符串是否全部是字母(包括大小写),

     <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.8.16</version>
        </dependency>

2.复制一下代码执行

import cn.hutool.core.lang.Validator;
public class Test {
    public static void main(String[] args) throws Exception{

        String word1 = "abcDEFG";
        String word2 = "12abc";
        if (Validator.isWord(word1)) {
            System.out.println(word1+"字符串全是字母");
        }else {
            System.out.println(word1+"字符串不全是字母");
        }

        if (Validator.isWord(word2)) {
            System.out.println(word2+"字符串全是字母");
        }else {
            System.out.println(word2+"字符串不全是字母");
        }
    }
}


本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表