How do I check if a Java String contains at least one capital letter, lowercase letter, and number?

前端 未结 7 1625
孤城傲影
孤城傲影 2020-12-16 12:38

I know that I could do this with a series of for loops that iterate through the string but that would be terrible programming. Well, my professor prefers I don\'t do it this

7条回答
  •  [愿得一人]
    2020-12-16 12:43

    you can use :

    public static boolean isTextContainUpperCase(String text) {
           if (StringUtils.isEmpty(text)) {
                  return false;
           }
           return !text.equals(text.toLowerCase());
    }
    

提交回复
热议问题