Here you can find the source of countChar(final String host, final char charactor)
Parameter | Description |
---|---|
host | a parameter |
charactor | a parameter |
public static int countChar(final String host, final char charactor)
//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; } }