Java判断是否为数字

String s1 = "a"; Pattern pattern = Pattern.compile("[0-9]*"); Matcher isNum = pattern.matcher(s1); if (isNum.matches()) { int h = Integer.parseInt(s1); System.out.println(h); } else { System.out.println("不是数字!"); }

原文地址:https://www.cnblogs.com/214829qw/p/5124005.html