class Main { public static void main(String[] args) { int i=0; for(char c:"My name is Tom,I come from China.".toCharArray()){ if(Character.isUpperCase(c)){ System.out.print(c+""); i++; } } System.out.println(); System.out.print("大写字母的个数是:"+i); } }