Java Char Count charCount(final String s, final char c)

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

Description

char Count

License

Apache License

Declaration

public static final int charCount(final String s, final char c) 

Method Source Code

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

public class Main {

    public static final int charCount(final String s, final char c) {
        int r = 0;
        for (int i = 0, len = s != null ? s.length() : 0; i < len; i++) {
            if (c == s.charAt(i)) {
                r++;/*from  w ww  .  j  av  a 2s.c o m*/
            }
        }
        return r;
    }
}

Related

  1. charCount(final String s, final char c)
  2. charCount(int codePoint)
  3. charCount(String s, char c)
  4. charCount(String source, char target)
  5. charCount(String str, char c, boolean countEscaped)