用Double.parseDouble(string),如果捕到异常,则说明不是数字。

解决方案 »

  1.   

    具体类型的判断我只在jxl.jar包里面的方法
    c00.getType()实现过,具体还有没有其他的方法来实现,具体去查询一下!关注!
      

  2.   

    你可以考虑使用正则表达式来判断是否是数字.如果是数字,呃,我问你2是一个什么类型,int or long or other types?
      

  3.   

    不要用异常来判断,影响效率,而且用异常控制流程是个非常差的习惯 public static boolean isNumber(String s)
    {
    boolean pointfirsttime = true; int i = 0;
    if (s == null) {
    return false;
    }

    if (s.charAt(0) == '-') {
    i++;
    }

    while (i < s.length()) {
    if (!Character.isDigit(s.charAt(i))) {
    if ('.' == s.charAt(i) && pointfirsttime) {
    pointfirsttime = false;
    } else {
    return false;
    }
    }
    i++;
    }
    return true;
    }至于是什么类型,不好说吧
      

  4.   

    try:String data = "这里放你要想匹配的字符串";
    String pattern = "^\\s*(\\+|-)?\\d+(\\.\\d+)?\\s*$";
    Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(data);
        if(m.matches())
          System.out.println("match");
        else
          System.out.println("not match");