Here you can find the source of charCount(String s, char c)
public static int charCount(String s, char c)
//package com.java2s; public class Main { public static int charCount(String s, char c) { int res = 0; for (char ch : s.toCharArray()) if (ch == c) res++;//from www . j a v a 2s . co m return res; } }