Java Char Count countChars(final String string, final String findStr)

Here you can find the source of countChars(final String string, final String findStr)

Description

Returns the number of appearces of "character" in "string".

License

Open Source License

Parameter

Parameter Description
string String
findStr String

Return

Integer

Declaration

public static Integer countChars(final String string, final String findStr) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w w w.ja v  a 2  s  .  co  m
     * Returns the number of appearces of "character" in "string".
     * 
     * @param string
     *            String
     * @param findStr
     *            String
     * 
     * @return Integer
     */
    public static Integer countChars(final String string, final String findStr) {
        String strCopy = new String(string);
        return strCopy.replaceAll("[" + findStr + "]", "").length();
    }
}

Related

  1. countCharacters(String str, char chr)
  2. countCharInString(String s, char c)
  3. countChars( final String testString, final char match )
  4. countChars(final String str, final char c)
  5. countChars(final String str, final char chr)