Accumulating over a traversal
Combine the two patterns you know: traverse a string, and keep a running count. Look at each character with charAt, test it, and update a counter when it matches. Characters are compared with == and a single-quote literal like 'a'.