Here you can find the source of charCount(final String s, final char c)
public static final int charCount(final String s, final char c)
//package com.java2s; //License from project: Apache License public class Main { public static final int charCount(final String s, final char c) { int r = 0; for (int i = 0, len = s != null ? s.length() : 0; i < len; i++) { if (c == s.charAt(i)) { r++;/*from w ww . j av a 2s.c o m*/ } } return r; } }