Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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();
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #number #occurrences #substring #string #java
ADD COMMENT
Topic
Name
7+1 =