题解 | #统计大写字母个数#
统计大写字母个数
https://www.nowcoder.com/practice/434414efe5ea48e5b06ebf2b35434a9c
package com.example.demo.simple;
import java.util.Scanner;
/**
* 【统计大写字母个数】
*
*/
public class Main_38 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String nextLine = sc.nextLine();
int count = 0;
char[] chars = nextLine.toCharArray();
for (char aChar : chars) {
if (Character.isUpperCase(aChar)) {
count++;
}
}
System.out.println(count);
}
}
查看19道真题和解析