Triple777er
Triple777er

Reputation: 631

Storing a probability for a hashmap value

I have a hashmap where I am reading a text file and storing the unique words into key and the number of frequency of that specific word in another textfile in the value field.

Now, I have to keep track of the probability of the word occurring in another text file. I don't need to know how to calculate the probability, but however, what I need to figure out is, how do I store the probability associated with every key (word) when the value field is already taken (frequency of words).

Do you suggest I make another hashmap with the same keys but replace the values with the probability? Thanks!

Upvotes: 0

Views: 602

Answers (1)

SLaks
SLaks

Reputation: 887469

You should make a class that holds both pieces of information, and store that class in a single hashmap.

Upvotes: 5

Related Questions