question: public static int countSubstrings ( String string , String sub ) { int count = 0 ; int index = - 1 ; while ( ( index = string . indexOf ( sub , index + 1 ) ) != - 1 ) { ++ count ; } return count ; }
target:  Counts the number of substring in a string