找出给定字符串中大写字符(即'A'-'Z')的个数。
统计大写字母个数
http://www.nowcoder.com/questionTerminal/434414efe5ea48e5b06ebf2b35434a9c
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
String nextLine = scanner.nextLine();
int count = 0;
for (int i = 0; i < nextLine.length(); i++) {
if (Character.isUpperCase(nextLine.charAt(i))) {
count++;
}
}
System.out.println(count);
}
}}
查看22道真题和解析