code: private int countOccurrences(String haystack, char needle) {
          int count = 0;
          for (int i = 0; i < haystack.length(); i++) {
              if (haystack.charAt(i) == needle)
                  count++;
          }
          return count;
      }
docs: Count how many time needle appears in haystack
  @param haystack
  @param needle
  @return