四种情况,没什么难点。

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String str = in.nextLine();
            int letter = 0;
            int space = 0;
            int num = 0;
            int other = 0;
            for(int i = 0; i < str.length(); i++){
                char c = str.charAt(i);
                if((c >= 'a' && c <= 'z')||(c >= 'A' && c <= 'Z')){
                    letter++;
                }
                else if(c >= '0' && c <= '9'){
                    num++;
                }
                else if(c == ' '){
                    space++;
                }
                else{
                    other++;
                }
            }
            System.out.println(letter);
            System.out.println(space);
            System.out.println(num);
            System.out.println(other);
        }
    }
}