@Nonnegative
    public static int countSubString(@Nonnull String string, @Nonnull String sub) {
        int count = 0;
        int pos = 0;
        do {
            pos = string.indexOf(sub, pos);
            if (pos != -1) {
                count++;
                pos += sub.length();
            }
        } while (pos != -1);
        return count;
    }
@Nonnegative
    public static int countSubString(@Nonnull String string, @Nonnull String sub) {
        int count = 0;
        int pos = 0;
        do {
            pos = string.indexOf(sub, pos);
            if (pos != -1) {
                count++;
                pos += sub.length();
            }
        } while (pos != -1);
        return count;
    }
@ Nonnegative public static int countSubString ( @ Nonnull String string , @ Nonnull String sub ) { int count = 0 ; int pos = 0 ; do { pos = string . indexOf ( sub , pos ) ; if ( pos != - 1 ) { count ++ ; pos += sub . length ( ) ; } } while ( pos != - 1 ) ; return count ; }
Count the number of occurrences of sub in s
Count the number of occurrences of sub in s