Think about it.
If you still can't come up with any code - working or otherwise - maybe you need to back-track and cover the basics one more time. Read the java tutorials. Talk to your teacher or classmates about the problem, etc.
Look at the problem from a real-world perspective. You have a sentence in front of you, how many times doesn the word "sentence" appear in that sentence? How do you know? What did you have to do to figure that out? Haw mana a's ara an thas santanca? How did you figure that out? Can you make java do the same thing?
~Chaars