1public class StringNumberOfOccurenceLetter {
2
3 private static int countOccurences(String word, char character){
4
5 int count = 0;
6 for (int i = 0; i < word.length() ; i++) {
7 if (word.charAt(i)==character){
8 count++;
9 }
10 }
11 return count;
12
13 }
14 public static void main(String[] args) {
15
16
17 int count = countOccurences("dddssad", 'a');
18 }
19
20
21}
1public static int count(String str, String target) {
2 return (str.length() - str.replace(target, "").length()) / target.length();
3}
4