一起练习:
1.ACM模式,输入输出ACM模式
2.核心代码模式,处理真正的业务
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String str = scanner.nextLine();
        str = str.toUpperCase();

        Character ch = scanner.nextLine().charAt(0);
        ch = Character.toUpperCase(ch);

        int num = coreCode(str, ch);
        System.out.println(num);

    }

    private static int coreCode(String str, Character ch) {

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < str.length(); i++) {
            Character c = str.charAt(i);
            //如果为空,设为1; 不为空 +1
            if (map.get(c) == null) {
                map.put(c, 1);
            } else {
                map.put(c, map.get(c) + 1);
            }
        }
        //判断字符是否存在字符串
        return map.get(ch) == null ? 0 : map.get(ch);
    }
}