java check how many times a character is in a string code example
Example 1: how to test how many of one character is in a string java
int count = string.length() - string.replaceAll("g","").length()
Example 2: check how many times a character appears in a string java
str.chars().filter(num -> num == '$').count()