Here you can find the source of countChars(final String string, final String findStr)
Parameter | Description |
---|---|
string | String |
findStr | String |
public static Integer countChars(final String string, final String findStr)
//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(); } }