count how many times a char appears in a string java code example Example: check how many times a character appears in a string java str.chars().filter(num -> num == '$').count()