11智能在线
新记
在java中如何判断一个字符是不是整数
如题所述
举报该文章
相关建议 2010-11-14
Integer.parseInt( str );将字符转化为整数,如果不能转化则会抛出异常,说明不是整数
你用try-catch来捕获此异常,得到异常便不是整数啦
具体看看:
http://hi.baidu.com/top_beidu/blog/item/d733d026230c65e3d7cae21c.html
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/fm4vpfpf8.html
其他看法
第1个回答 2010-11-14
public static boolean isInt(String str){
if(str.matches("[1-9]\\d*"))
return true;
return false;
}
第2个回答 2010-11-14
判断字符串里是否含有小数点不就得了
第3个回答 2010-11-14
fix(a)<>a
相似回答
大家正在搜
相关问题
java怎样判断一个字符串是否为整数和浮点数?
java中判断一个字符串是否是一个整数的几个方法
【Java】从键盘输入一个字符串,怎么判断是不是整数数字格式...
java如何判断一个字符是不是中文?
java中判断输入的是否是整数
java如何判断是一个字符串有多少字符
在java中如何对输入的内容进行判断它是字符串还是整型?
【Java】从键盘输入一个字符串,判断是否是整数数字格式的字...