Here you can find the source of countChar(String text, char ch)
private static int countChar(String text, char ch)
//package com.java2s; //License from project: BSD License public class Main { private static int countChar(String text, char ch) { int count = 0; int length = text.length(); for (int i = 0; i < length; i++) if (text.charAt(i) == ch) count++;/*from ww w . j a va 2 s . co m*/ return count; } }