public boolean isNumber(String str) {
String strValidChars = "0123456789";
char strChar;
boolean isSuccess = true;
if (str.length() == 0) return true;
for (int i = 0; i < str.length() && isSuccess == true; i++) {
strChar = str.charAt(i);
if (strValidChars.indexOf(strChar) == -1) {
isSuccess = false;
}
}
return isSuccess;
}
public boolean isAlphabet(String str) {
String strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
char strChar;
boolean isSuccess = true;
if (str.length() == 0) return true;
for (int i = 0; i < str.length() && isSuccess == true; i++) {
strChar = str.charAt(i);
if (strValidChars.indexOf(strChar) == -1) {
isSuccess = false;
}
}
return isSuccess;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment