package com.sf._03_str;

public class Test3 {
    public static void main(String[] args) {
        statisticsCharCount("abceacab",'a');
    }

    public static void statisticsCharCount(String name,char target){
        // 字符串 -> 字符数组   abacad
        //[a,b,a,c,a,d]
        char[] chars = name.toCharArray();
        int count = 0;
        for (char ch : chars) {
            if(ch == target){
                count++;
            }
        }
        System.out.println("目标字符出现次数:"+ count);
    }
}
