判断字符串中的数字个数:?
public static void main(String[] args) {
? ? ? ? System.out.println(isnumberic("wadas54asd2aw3"));
? ? }
? ? public static int isnumberic(String str){
? ? ? ? int count=1;
? ? ? ? for(int i=0;i<str.length();i++)
? ? ? ? {
? ? ? ? ? ? ? ? if(Character.isDigit(str.charAt(i))){? ?//判断字符是否为数字
? ? ? ? ? ? ? ? count++;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? return count;
? ? }
本文系转载,前往查看
如有侵权,请联系?cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系?cloudcommunity@tencent.com 删除。