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("不是数字!"); }
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("不是数字!"); }