第1个回答 2015-03-30
String str = "";
int n = 0;
try{
n = Integer.parseInt(str);
System.out.println("str是数字!);
}catch (Exception e) {
// TODO: handle exception
System.out.println("str不是数字!");
return;
}
第2个回答 2017-07-29
try {
String str="123abc";
//把字符串强制转换为数字
int num=Integer.valueOf(str);
//如果是数字,返回True
return true;
} catch (Exception e) {
//如果抛出异常,返回False
return false;
}
第3个回答 2017-07-28
if(z==int(z)){prt("整形")}或者整型/整型=整型所以结果Z一定是整型,不需要判断但是如果你想判断的话可以这样Z=(L-x+y)/(n-m);temp=(L-x+y)/(float)(n-m);这个时候只要判断(temp>Z)?就可以了
第4个回答 2017-07-29
inta=Integer.parseInt(你输入的字符串);if(Math.abs(a)>999andMath.abs(a)<10000){//是4位整数}else{//不是4位整数}