Here you can find the source of countChar(CharSequence chars, char c)
public static int countChar(CharSequence chars, char c)
//package com.java2s; public class Main { public static int countChar(CharSequence chars, char c) { int count = 0; for (int i = 0; i < chars.length(); i++) { if (chars.charAt(i) == c) count++;//w w w . j a v a 2s. co m } return count; } }