Java Char Count charCount(String str, char sub)

Here you can find the source of charCount(String str, char sub)

Description

char Count

License

Open Source License

Declaration

public static int charCount(String str, char sub) 

Method Source Code

//package com.java2s;

public class Main {

    public static int charCount(String str, char sub) {
        int charCount = 0;
        int fromIndex = 0;

        while ((fromIndex = str.indexOf(sub, fromIndex)) != -1) {
            fromIndex++;/* w w w. j  av  a2s . c  o  m*/
            charCount++;
        }
        return charCount;
    }
}

Related

  1. charCount(int codePoint)
  2. charCount(String s, char c)
  3. charCount(String source, char target)
  4. charCount(String str, char c, boolean countEscaped)
  5. charCount(String str, char chr)
  6. charCount(String subject, String needle)
  7. charCountRight(String str, String sub)
  8. countChar(char charIn, String stingIn)
  9. countChar(char[] line, char target_char)