Java String Char Count countChars(String s, String charset)

Here you can find the source of countChars(String s, String charset)

Description

count Chars

License

CDDL license

Declaration

public static int countChars(String s, String charset) 

Method Source Code

//package com.java2s;
//License from project: CDDL license 

public class Main {
    public static int countChars(String s, String charset) {
        int nc = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (charset.indexOf(c) >= 0)
                nc++;// ww w . j av a  2s.  c o  m
        }
        return nc;
    }
}

Related

  1. countChars(String input)
  2. countChars(String s, boolean countDigits, boolean countLetters, boolean countOthers)
  3. countChars(String s, char c)
  4. countChars(String s, char c)
  5. countChars(String s, char c)
  6. countChars(String string, char c)
  7. countChars(String string, int character)
  8. countChars(String text, char ch, int from, int to)
  9. countCharsInString(final String stringToCountOccurrancesIn, final char characterToCount)