Here you can find the source of countChar(String str, char c)
public static int countChar(String str, char c)
//package com.java2s; //License from project: LGPL public class Main { public static int countChar(String str, char c) { char[] chars = str.toCharArray(); int count = 0; for (char d : chars) { if (d == c) { count++;//from w w w. ja v a 2 s. c om } } return count; } }