User Input Validation, enforcing a string containing only letters

后端 未结 4 1238

Im trying to make a user input validation system within one of my methods... its working fine to a cetain extent, but despite the code, its still allowing for integers as valid

4条回答
  •  醉梦人生
    2021-01-29 10:48

    Try something like"

    if (!userName.matches(".*\\d+.*")) {
        System.out.println("Only strings no numbers");
    }
    

提交回复
热议问题