Java Char Count countChar(final String host, final char charactor)

Here you can find the source of countChar(final String host, final char charactor)

Description

count char in host string

License

Open Source License

Parameter

Parameter Description
host a parameter
charactor a parameter

Declaration

public static int countChar(final String host, final char charactor) 

Method Source Code

//package com.java2s;
/*// w  ww .  ja v  a2s .  c  om
 *
 * Copyright c 2005-2009.
 * 
 * Licensed under GNU  LESSER General Public License, Version 3.  
 * http://www.gnu.org/licenses
 * 
 */

public class Main {
    /**
     * count char in host string
     * 
     * @param host
     * @param charactor
     * @return
     */
    public static int countChar(final String host, final char charactor) {
        int count = 0;
        for (int i = 0; i < host.length(); i++) {
            if (host.charAt(i) == charactor) {
                count++;
            }
        }
        return count;
    }
}

Related

  1. countChar(char charIn, String stingIn)
  2. countChar(char[] line, char target_char)
  3. countChar(CharSequence chars, char c)
  4. countChar(final int[] locator, final char c)
  5. countChar(final String aString, final char aChar)
  6. countChar(int start_index, int end_index, StringBuffer txt, char c)
  7. countChar(String a_text, char a_character)
  8. countCharacter(final String sourceString, final char lookFor)
  9. countCharacter(String content, char character)