Answers for "number of occurence in string"

0

number of occurence in string

public class StringNumberOfOccurenceLetter {

    private static int countOccurences(String word, char character){

        int count = 0;
        for (int i = 0; i < word.length() ; i++) {
            if (word.charAt(i)==character){
                count++;
            }
        }
        return count;

    }
         public static void main(String[] args) {


        int count = countOccurences("dddssad", 'a');
    }

}
Posted by: Guest on January-14-2021

Code answers related to "number of occurence in string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language