Here you can find the source of countChar(int start_index, int end_index, StringBuffer txt, char c)
public static int countChar(int start_index, int end_index, StringBuffer txt, char c)
//package com.java2s; //License from project: Apache License public class Main { public static int countChar(int start_index, int end_index, StringBuffer txt, char c) { int count = 0; for (int i = start_index; i <= end_index; i++) { if (txt.charAt(i) == c) { count++;// w w w .j ava 2 s .c o m } } return count; } }