Here you can find the source of countChars(final String str, final char c)
final public static int countChars(final String str, final char c)
//package com.java2s; // License as published by the Free Software Foundation; either public class Main { final public static int countChars(final String str, final char c) { int count = 0; for (int i = 0; i < str.length(); ++i) { if (str.charAt(i) == c) { ++count;/*from w ww . j a v a 2 s . co m*/ } } return count; } }