SyntaxFix
Write A Post
Hire A Developer
Questions
you can also use a for each loop. I think it is simpler to read.
int occurrences = 0; for(char c : yourString.toCharArray()){ if(c == '$'){ occurrences++; } }