Here you can find the source of getCharNum(String str, char ch)
public static int getCharNum(String str, char ch)
//package com.java2s; public class Main { public static int getCharNum(String str, char ch) { int num = 0; for (int i = 0; i < str.length(); ++i) { if (str.charAt(i) - ch == 0) { num++;//from w ww . ja v a 2 s. c o m } } return num; } }