code: @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;
      }
docs: Count the number of occurrences of sub in s