Java String Char Count countChar(String text, char ch)

Here you can find the source of countChar(String text, char ch)

Description

count Char

License

BSD License

Declaration

private static int countChar(String text, char ch) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    private static int countChar(String text, char ch) {
        int count = 0;
        int length = text.length();
        for (int i = 0; i < length; i++)
            if (text.charAt(i) == ch)
                count++;/*from ww  w . j  a  va  2  s .  co  m*/
        return count;
    }
}

Related

  1. countChar(String str, char chr)
  2. countChar(String str, char reg)
  3. countChar(String string, char c, int pos, boolean forwards)
  4. countChar(String string, String c)
  5. countChar(String text, char c)
  6. countChar(StringBuffer sb, char ch)
  7. countChars(String data)
  8. countChars(String input)
  9. countChars(String s, boolean countDigits, boolean countLetters, boolean countOthers)