Java Maps Part 3: use HashMap to find number of word occurrences in a file

preview_player
Показать описание

How to use a HashMap to find the number of word occurrences in a file and then find the most frequently used word.

Also a pretty good and basic java hashmap interview problem.
Рекомендации по теме
Комментарии
Автор

HashMap is a data structure that you can use to do a O(1) lookup. So, although you have a feature to iterate over the HashMap, using it wouldn't be effecient. A better way to find a word with maximum frequency is to have a variable for it and update it during insertion into the hashmap itself

sril
Автор

how would go about printing the top 20 most occurring words ?

walterbryne
Автор

Hi, I want know how can you exclude some words from a txt file. For ex. "the", "and"

tamtamns
Автор

how do we count the frequency of a specific word?

Lanzengying
Автор

I followed what you did in the video and saved my text file where the project is, but im getting this error. Any ideas?
Exception in thread "main" (The system cannot find the file specified)
at Method)
at Source)
at Source)
at Source)
at Main.main(Main.java:16)

walterbryne