MissouriTiger
Programmer
Hi,
This is my first time parsing strings in Java. As part of my password & username screens, I'm calling the method below to test the input for invalid characters. I'm only allowing numbers, letters, and "_". The compiler is generating multiple errors, but the main problem seems to involve my casting operation (char to Character). I can't see anything wrong with it. I sure would appreciate some help.
public boolean characterScreen(String s)
{
Character c;
for (int i = 0 ; i < s.length() ; i++)
{
c = (Character)(s.charAt(i));
if ((!isLetterOrDigit(c)) && (getNumericValue(c) != 63))
return false;
}
return true;
}
This is my first time parsing strings in Java. As part of my password & username screens, I'm calling the method below to test the input for invalid characters. I'm only allowing numbers, letters, and "_". The compiler is generating multiple errors, but the main problem seems to involve my casting operation (char to Character). I can't see anything wrong with it. I sure would appreciate some help.
public boolean characterScreen(String s)
{
Character c;
for (int i = 0 ; i < s.length() ; i++)
{
c = (Character)(s.charAt(i));
if ((!isLetterOrDigit(c)) && (getNumericValue(c) != 63))
return false;
}
return true;
}