Java Char Count countCharacterOccurrences(String string, char c)

Here you can find the source of countCharacterOccurrences(String string, char c)

Description

count Character Occurrences

License

Open Source License

Declaration

private static Object countCharacterOccurrences(String string, char c) 

Method Source Code

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

public class Main {
    private static Object countCharacterOccurrences(String string, char c) {
        int result = 0;
        int length = string.length();
        for (int i = 0; i < length; i++) {
            if (string.charAt(i) == c) {
                result++;//  w  w w. ja  v  a2s  . co m
            }
        }
        return result;
    }
}

Related

  1. countChar(final String host, final char charactor)
  2. countChar(int start_index, int end_index, StringBuffer txt, char c)
  3. countChar(String a_text, char a_character)
  4. countCharacter(final String sourceString, final char lookFor)
  5. countCharacter(String content, char character)
  6. countCharacters(String code, char c, int start, int end)
  7. countCharacters(String str, char chr)
  8. countCharInString(String s, char c)
  9. countChars( final String testString, final char match )