在java中如何判断一个字符是不是整数

如题所述

Integer.parseInt( str );将字符转化为整数,如果不能转化则会抛出异常,说明不是整数
你用try-catch来捕获此异常,得到异常便不是整数啦
具体看看:
http://hi.baidu.com/top_beidu/blog/item/d733d026230c65e3d7cae21c.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
相似回答