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

posted on 2016-01-12 13:04  ip权  阅读(194)  评论(0)    收藏  举报