import java.util.Scanner;
public class Test{
public static int countUppercase(String s){
int count = 0;
for(int i = 0; i<s.length(); i++){
if(s.charAt(i)>='A'&&s.charAt(i)<='Z'){
count++;
}
}
return count;
}
public static void main(String[] args){
System.out.println("Please enter a word to check for uppercase:");
Scanner input = new Scanner(System.in);
String s=input.nextLine();
countUppercase(s);
}
}
为什么这段代码不起作用?它只接受输入但不返回计数!