Find the number of occurrences of substring in string followed by 'a" code example
Example: find number of occurrences of a substring in a string java
public static int count(String str, String target) {
return (str.length() - str.replace(target, "").length()) / target.length();
}