public boolean checkNum(String args){
Pattern p=Pattern.compile("^[\d]*");
Matcher m=p.matcher(args);
if(m.matches())
return true;
else
return false;
}

解决方案 »

  1.   

    Pattern p=Pattern.compile("^[\d]*$");
      

  2.   

    先赋值给double然后再转换成字符串...
      

  3.   

    String str="adb";
    double test=0.0;
    try
    {
     test=Double.parseDouble(str);
    }
    catcj(Exception ex)
    {
          System.out.print("error:"+ex.getMessage());
    }
      

  4.   

    我想要的是 写一个方法 传一个参数为STRING类型的 
    然后进行判断 判断他不能为字母  只能为数字 这个方法的返回类型是  STRING 
    返回这个数
      

  5.   

    public String checkNumber(String st){
      if(st.matches("[\\d]*"))
       return st;
      else
       return "";
    }
      

  6.   

    J2EE技术交流群:9438177
    帮助第一,互相交流,共同进步!记住:分享与贡献同等重要!
      

  7.   

    楼上写的是js自带的验证???......人家明明要java的 ......