// File: Occurrences.java
// Time-stamp: "2005-01-09 11:50:52 calvanese"

/* 
   Static method that, given a string s and a character c, returns the
   number of occurrences of c in s.
*/

public class Occurrences {

  public static int occurrences(String s, char c) {
    if (s.equals(""))
      return 0;
    else if (s.charAt(0) == c)
      return 1 + occurrences(s.substring(1), c);
    else
      return occurrences(s.substring(1), c);
  }
}
