Answers for "count the number of substring present in the given string in java"

0

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();
}
Posted by: Guest on October-29-2020

Code answers related to "count the number of substring present in the given string in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language