You can use regular expressions.
String input = ...
if (input.matches("[^a-zA-Z0-9 ]"))
If your definition of a 'special character' is simply anything that doesn't apply to your other filters that you already have, then you can simply add an else
. Also note that you have to use else if
in this case:
if(c == ' ') {
blankCount++;
} else if (Character.isDigit(c)) {
digitCount++;
} else if (Character.isLetter(c)) {
letterCount++;
} else {
specialcharCount++;
}