码迷,mamicode.com
首页 > 其他好文 > 详细

统计字符串中某个字符的个数

时间:2018-10-25 15:44:15      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:nal   字符串   vat   turn   code   rar   null   ++   字符   

    private int countNum(final String str, final char ch){
        int num = 0;
        if (str != null){
            for(char i: str.toCharArray()){
                if(i==ch){
                    ++num;
                }
            }
        }
        return num;
    }

 

统计字符串中某个字符的个数

标签:nal   字符串   vat   turn   code   rar   null   ++   字符   

原文地址:https://www.cnblogs.com/wenlin-gk/p/9849679.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!