It keeps saying that the method must return a result of type int but I already made return the result.
import java.util.Scanner;
public class chap9 {
public static void main (String[] args) {
String message = "statement";
char letter = 'a';
int num = count(message,letter);
}
public static int count(String str, char a){
Scanner input = new Scanner(System.in);
System.out.println("Enter the string");
str = input.nextLine();
int length = str.length();
for(int i =0; i<length; i++) {
a= 'a';
int occurence =0;
char b = str.charAt(i);
if( b==a){
occurence++;
}
return occurence;
}
}
}