I want to test wheather my input string conatins any special characters or not. Is there any good techniques for impelmting this?
I am using charAt() and ASCII values
for(int i=0;i<s.length();i++)
{
char c=s.charAt(i);
if(65<=c<=90)
{
System.out.println("Valid");
}
else if(97<=c<=122)
{
System.out.println("Invalid as it contains lower case letter");
break;
}
else if(48<=c<=57)
{
System.out.println("Invalid as it contains numbers");
break;
}
else
System.out.println("Invalid as it contains special characters");
}
Anonymous User
29-Dec-2015