public class Main {
public static void main(String[] args) {
String s = "1Hello**World!";
char[] array = s.toCharArray();
int lowerCase = 0;
int upperCase = 0;
int nonAlpha = 0;
for (char c : array) {
if (c>=65 && c<=90) {
upperCase++;
} else if (c>=97 && c<=122) {
lowerCase++;
} else {
nonAlpha++;
}
}
System.out.println(upperCase);
System.out.println(lowerCase);
System.out.println(nonAlpha);
}
}
网友评论