Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static int countOccurence(String matchedString, char occurence) { int count = 0; for (final char c : matchedString.toCharArray()) { if (c == occurence) { ++count; } } return count; } }