

After all words are scanned, run one for loop to read all key-value pairs. Any suggestions Expand Select Wrap Line Numbers. I thought to do this foreach to delete the word (but I dont like this way). Im new to Java and Its not clear to me how work/retrieve the content of a hash map see this below. Now, I need to delete the word with highest frequency.

Else store value as 1 for that key (word). I have an hasmap with some words and their frequecy. If the word is already stored in the map, increase the count and store the updated count as value for that word. You are currently iterating the queue three times if the queue contains the word ( contains, iterator loop, remove), this can be reduced to one iteration by only using the iterator. The first thing you need to do is grab a text file in which you have to perform the operation of counting the word occurrences example I have a file named shubham.txt in which I will be counting the occurrences of each word. Check if the HashMap contains that word or not. You can reduce the variable scope of your static variables by accepting the array input as parameter and returning the queue.
