That will certainly work, and it is probably the method I would adopt. There is one additonal possibility:
public boolean isNumber(final String target) {
char[] chars = target.toCharArray();
for (int current = 0; current < chars.length; current++) {
if (! Character.isDigit(chars[current]))
return false;
}
return true;
}
- Saish
"My karma ran over your dogma." - Anon
> Your additional solution doesn't really work because it needs to check to see if the value exceeds the integer size limit. It will work in situations where you sure you won't have that problem though.
Point taken. My example was mainly for illustrative purposes.
- Saish
"My karma ran over your dogma." - Anon