题解 | #计算某字母出现次数#

计算某字母出现次数

http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1

调用String的equalsIgnoreCase()方法比较
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String str1 = sc.nextLine();
            String str2 = sc.nextLine();
            char[] chsArray = str1.toCharArray();
            int count = 0;
            for(int i = 0;i < chsArray.length;i++){
                if((chsArray[i]+"").equalsIgnoreCase(str2)){
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}


全部评论

相关推荐

09-17 10:53
四川大学 C++
牛客91242815...:会写标书没有任何卵用,鉴定为横向垃圾导师的受害者
点赞 评论 收藏
分享
09-01 09:00
已编辑
四川旅游学院 运营
牛客55195891...:主要是专业不好,别的没毛病
牛客解忧铺
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务