public static int countOccurrencesOf(String s,char c){
  if (s == null || s.length() == 0)   return 0;
  char[] chars=s.toCharArray();
  int count=0;
  for (  char aChar : chars)   if (aChar == c)   count++;
  return count;
}

public static int countOccurrencesOf ( String s , char c ) { if ( s == null || s . length ( ) == 0 ) return 0 ; char [ ] chars = s . toCharArray ( ) ; int count = 0 ; for ( char aChar : chars ) if ( aChar == c ) count ++ ; return count ; }
count the occurrences of the character c in string s .
