NutzCN Logo
问答 Nutz类库中有没有类似判断某个字符串,能不能转为数字的函数?
发布于 2331天前 作者 qq_7fafbecc 1512 次浏览 复制 上一个帖子 下一个帖子
标签:

例如str1="张三" str2="12.5"
明显str2能转为数字,str1不能
有没有函数能够进行判断,返回true或者false ?

2 回复

Strings.isNumber

算了,已经用了这个了

try {  
    Integer.parseInt(str);  
    return true;  
} catch (NumberFormatException e) {  
    return false;  
}  
添加回复
请先登陆
回到顶部