题解 | #统计字符串中字母出现次数#

统计字符串中字母出现次数

http://www.nowcoder.com/practice/83350872bdb5406fa706895d5efb1c55

public class outtimes {

public static void main(String[] args) {
    String string = "H e l l o ! n o w c o d e r";
    Scanner scanner= new Scanner(System.in);
    String word = scanner.next();
    scanner.close();
    System.out.println(check(string, word));
}

public static int check(String str, String word) {

    return str.length() - str.replace(word, "").length();
}

}

全部评论

相关推荐

02-27 15:08
门头沟学院 Java
春招第一枪拷打实习挑一个项目介绍一下手撕归并排序
滴滴滴d:我昨天也面了,感觉答得还行,结果秒挂
查看2道真题和解析
点赞 评论 收藏
分享
Lyxiho:浙江大学 加大加粗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务