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