How to check a string starts with numeric number?

前端 未结 6 2026
野趣味
野趣味 2021-02-06 20:44

I have a string which contains alphanumeric character.

I need to check whether the string is started with number.

Thanks,

6条回答
  •  误落风尘
    2021-02-06 20:58

    See the isDigit(char ch) method:

    https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Character.html

    and pass it to the first character of the String using the String.charAt() method.

    Character.isDigit(myString.charAt(0));
    

提交回复
热议问题