public static int count(String source,char character){
  int result=0;
  for (int i=0; i < source.length(); i++) {
    if (source.charAt(i) == character) {
      result++;
    }
  }
  return result;
}

public static int count ( String source , char character ) { int result = 0 ; for ( int i = 0 ; i < source . length ( ) ; i ++ ) { if ( source . charAt ( i ) == character ) { result ++ ; } } return result ; }
a fast utility method that does ' nt use regex and returns the number of character in source .
