1public class CountStringOccurence {
2public static void main(String[] args) {
3
4int count= countOccurences("aaassssddadad",'s');
5System.out.println(count);
6
7}
8
9private static int countOccurences(String word, char character){
10
11 int count = 0;
12 for(int i = 0; i < word.length(); i++){
13
14 if(word.chartAt(i) == character){
15
16 count++; }
17 }
18 return count;
19}
20}