java中判断输入的数是实数还是 整数

如题所述

     //整数
     public static boolean isInt(String input) {
        return input.matches("\\d+");
    }
 
     //实数
    public static boolean isFloat(String input) {
        return input.matches("\\d+\\.\\d*");
    }

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答