Here is the code for count up string given as a second parameter appears on string given as a first parameter.
public final static int countOccurrence(String src, String search) { for(int count = 0, fromIndex = 0;;) { fromIndex = src.indexOf(search, fromIndex); if(fromIndex < 0) return count; fromIndex++; count++; } }
コメント