look at where your System.out.println statement is. it's inside the block where you check to see if two strings are equal. since no string ever matches 'america', you will never print anything out for the 'america' string.
for fun, try changing your input string to "I am in america. am in am".
you'll get even stranger results....
you don't want to print out the count as soon as you find a match, since you might find more than one match (as the above suggested string illustrates).
You need to keep a counter for each word you find. Personally, i'd suggest using a map with the word as the key, and an int counter as the value.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad: