当前位置: 技术问答>java相关
如何判断字符串是否是数字?
来源: 互联网 发布时间:2015-03-27
本文导语: 各位大虾,如何判断所输字符串是否是数字? | 在Java里要自己写 public boolean isNumericalString (String str){ str = str.toLowerCase(); String strTemp = str; char c = str.charAt(0); if (!(c=='+' || c=='-' ||...
各位大虾,如何判断所输字符串是否是数字?
|
在Java里要自己写
public boolean isNumericalString (String str){
str = str.toLowerCase();
String strTemp = str;
char c = str.charAt(0);
if (!(c=='+' || c=='-' || Character.isDigit(c)))
return false;
else if (c=='+' || c=='-') strTemp = str.substring(1);
int size = strTemp.length();
for (int i=0; i
public boolean isNumericalString (String str){
str = str.toLowerCase();
String strTemp = str;
char c = str.charAt(0);
if (!(c=='+' || c=='-' || Character.isDigit(c)))
return false;
else if (c=='+' || c=='-') strTemp = str.substring(1);
int size = strTemp.length();
for (int i=0; i