I was just wondering if there was a simple and easy way to test if a string(single char string) is a number.
Maybe some method I do not know about, or maybe something like
if (string[1].equals(\\#))
Any thoughts?
Name:
Anonymous2007-04-20 7:08 ID:mZDLYWuu
public class IsStringAnInteger {
private static IsStringAnInteger instance;
public IsStringAnInteger getInstance() {
if (instance == null) {
instance = new IsStringAnInteger();
}
return instance;
}[code]public class IsStringANumber {
private static IsStringANumber instance;
public IsStringANumber getInstance() {
if (in
public bool isStringAnInteger(String isThisStringAnInteger) {
boolean stringIsAnInteger = false;
int min = getMinimumInteger();
int max = getMaximumInteger();
for (int val = min; val <= max; val++) {
Integer integer = new Integer(val);
String stringWhichIsAnInteger = integer.toString();
if (isThisStringAnInteger.equals(stringWhichIsAnInteger)) {
stringIsAnInteger = true;
}
}
return stringIsAnInteger;
}
private int getMinimumInteger() {
return Integer.MIN_VALUE;
}
private int getMaximumInteger() {
return Integer.MAX_VALUE;
}