Java String Occurence Count countOccurences(String from, String word)

Here you can find the source of countOccurences(String from, String word)

Description

count Occurences

License

Open Source License

Declaration

public static int countOccurences(String from, String word) 

Method Source Code

//package com.java2s;
// it under the terms of the GNU Lesser General Public License as published by

public class Main {
    public static int countOccurences(String from, String word) {
        return (from.length() - from.replace(word, "").length()) / word.length();
    }//from w  w w  . ja v  a 2s.  c om
}

Related

  1. countOccurence(String matchedString, char occurence)
  2. countOccurences(String haystack, String needle)
  3. countOccurences(String s, char c)
  4. countOccurences(String str, int ch)
  5. countOccurences(String str, String subStr)