A.Adams A.Adams - 4 years ago 74
Java Question

how to display a list of all unique words that appear four or more times in the text?

So far, i have figured out how to get all the words to show, alongside the number which indicates how many times each unique word appears in the text. However, i cannot figure out how to get another list which displays all the unique words that ONLY occur 4 or more times. Any idea on how i can achieve this because i think i have done the hard bit here, but i would just like to know how i can get this next part.

Answer Source

Assuming that you are using Java 8, you can filter the entries in the countOcc map as follows based on the number of occurrences in the text. Finally, I have printed the filtered results.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download