BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String sSecond=br.readLine();//接收键盘录入值
//判断录入值是否为数值型
static boolean IsNumeric(String str){
Pattern pattern = Pattern.compile("([1-9][0-9]*)|([0-9])");
Matcher isNum = pattern.matcher(str);
if( !isNum.matches() ){
return false;
}
return true;
}
你可以参考一下 |