Java String Char Count countChar(String str, char c)

Here you can find the source of countChar(String str, char c)

Description

count Char

License

LGPL

Declaration

public static int countChar(String str, char c) 

Method Source Code

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

public class Main {
    public static int countChar(String str, char c) {
        char[] chars = str.toCharArray();
        int count = 0;
        for (char d : chars) {
            if (d == c) {
                count++;//from   w w w. ja  v a 2 s.  c om
            }
        }
        return count;
    }
}

Related

  1. countChar(String s, char c)
  2. countChar(String s, char c)
  3. countChar(String sql, int end)
  4. countChar(String src, char c)
  5. countChar(String str, char c)
  6. countChar(String str, char chr)
  7. countChar(String str, char reg)
  8. countChar(String string, char c, int pos, boolean forwards)
  9. countChar(String string, String c)