To count a specific char from a String, you can simply use the Spring framework.
import org.springframework.util.StringUtils; int occurance = StringUtils.countOccurrencesOf("012405802569015014", "0"); //returns 5 int occurance = StringUtils.countOccurrencesOf("hello world", "l"); //returns 3