Hello,
I have an hasmap with some words and their frequecy. Now, I need to delete the word with highest frequency. I'm new to Java and It's not clear to me how work/retrieve the content of a hash map; see this below. I thought to do this foreach to delete the word (but I don't like this way). Any suggestions?
thanks
I have an hasmap with some words and their frequecy. Now, I need to delete the word with highest frequency. I'm new to Java and It's not clear to me how work/retrieve the content of a hash map; see this below. I thought to do this foreach to delete the word (but I don't like this way). Any suggestions?
Code:
HashMap<String, Integer> text = new HashMap<String, Integer>();
int max = 0;
String word = null;
for (Integer freqOfWord : text.values() ) {
if ( freqOfWord > max ) {
max = freqOfWord;
word = //text.getActualWord() //how obtain the actual word?
}
}
// text.delete(word);
Comment