This is my homework, I am trying to get the occurrences of 'e' in strings of the array. My method doesn't seem to work. Can anyone wise person advise where did I go wrong?
import java.util.*;
import java.lang.*;
import java.io.*;
public class CountChar {
public static void main(String[] args) {
String[] strings
= {"hidden", "Java SDK", "DDD", "parameter", "polymorphism", "dictated", "dodged", "cats and dogs"};
int result = numberOfCharacters(strings, 'e');
System.out.println("No. of occurrences of 'e' is " + result);
}
public static String numberOfCharacters(String str, char a) {
int aresult = 0;
if (str.length() > 0) {
aresult = count(str.substring(1), a) + (str.charAt(0) == a ? 1 : 0);
}
return aresult;
}
}