Bob Gidlow

Greenhorn
+ Follow
since Jul 20, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bob Gidlow

Thanks, I have located my problem, I was "off by 1" in my logic,
this can be closed now
22 years ago
Is there a way to check if a character is alphanumeric. I was trying the code below but am picking up "all" characters. The string of data that I am checking should only have an alphanumeric in a particular position. I have the position part down pat but not the check. Did I need to "create" an alphanumeric table to compare. Thanks
/**
* Returns True if given String contains only numeric characters,
* otherwise returns False
*/
private boolean isNumeric(String newString)
{
char[] chars = newString.toCharArray();
Character c;
for (int x = 0; x < chars.length; x++)
{
if (!Character.isDigit(chars[x]))
{
return false;
}
}
return true;
}
/**
* Returns True if given String contains an alphanumeric,
* otherwise returns False
*/
public boolean isLetterOrDigit(String newString)
{
if ((newString == null) | | (newString.length()==0))
return false;
char[] chars = newString.toCharArray();
for (int x = 0; x < chars.length; x++)
{
if (!Character.isLetterOrDigit (chars [x]))
{
return false;
}
}
return true;
}//end method
22 years ago