A very similar algorithm would work for finding the number of occurrences of a char within a
String.
Note: - I posted a complete solution which did not show up in the replies, the message I got from JavaRanch staff was "attention required: your post requires editing before being shown in the forums / Please don't provide complete solutions.". So I am editing this post and converted part of it to pseudo code, maybe this policy is in place to "force" members to "learn
Java" :-) Hoping the above "pseudo code + code" meets the JavaRanch posting standard.