code: public static int countChar(String string, CharPredicate predicate)
      {
          int count = 0;
          int size = string.length();
          for (int i = 0; i < size; i++)
          {
              if (predicate.accept(string.charAt(i)))
              {
                  count++;
              }
          }
          return count;
      }
docs: Count the number of elements that return true for the specified {@code predicate}.
  
  @since 7.0