【非正则】判断一个字符串是否由数字组成

mac2022-06-30  79

package demo; public class Isnum { public static void main(String[] args) throws Exception { String num = "123"; System.out.println(isNumber(num)); } public static boolean isNumber(String str) { char [] data = str.toCharArray(); for (int x=0; x<data.length; x++) { if(data[x] > '9' || data[x] < '0') { return false; } } return true; } }

转载于:https://www.cnblogs.com/fanren224/p/8457179.html

相关资源:图的深度优先遍历和广度优先遍历算法
最新回复(0)