find count of substring in string java 8 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();
}