Java String Char Count countChars(String s, char c)

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

Description

count Chars

License

Open Source License

Declaration

private static int countChars(String s, char c) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static int countChars(String s, char c) {
        int count = 0;
        int index = -1;
        while ((index = s.indexOf(c, index + 1)) != -1) {
            count++;//from w w w.j a  v a 2 s  .c o m
        }
        return count;
    }
}

Related

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