protected int countChar(String str,int ch){
  int fromIndex=0;
  int count=0;
  while ((fromIndex=str.indexOf(ch,fromIndex)) != -1) {
    count++;
    fromIndex++;
  }
  return count;
}

protected int countChar ( String str , int ch ) { int fromIndex = 0 ; int count = 0 ; while ( ( fromIndex = str . indexOf ( ch , fromIndex ) ) != - 1 ) { count ++ ; fromIndex ++ ; } return count ; }
counts occurrences of a character in a string .
