Take a look at class java.lang.Character
static member methods (isDigit, isLetter, isLowerCase, ...)
Example:
String str = "Hello World 123 !!";
int specials = 0, digits = 0, letters = 0, spaces = 0;
for (int i = 0; i < str.length(); ++i) {
char ch = str.charAt(i);
if (!Character.isDigit(ch) && !Character.isLetter(ch) && !Character.isSpace(ch)) {
++specials;
} else if (Character.isDigit(ch)) {
++digits;
} else if (Character.isSpace(ch)) {
++spaces;
} else {
++letters;
}
}