Counting the fequency of word combinations
So Ive been working on this program which would take a sentence, create all possible word combinations and then record how many times that combination occurred. So far Ive been able to generate the word combinations with a 2d array. ex:
combinations   
W1 W1 1
W1 W2 1
W1 W3 1
... ... .
Wn Wn 1
Where the first two column are the combination and the frequency is an int in the third column. Right now I have my first two columns done but how would I go about adding that frequency to the combination?
I suppose I have a few questions:
1)Can I have one of the columns to an int (is that possible), if so how would I declare that/go about doing that?
2)Is there a better way to count the amount of times that a combination appears?
Thanks in advance.
Re: Counting the fequency of word combinations
You can not mix data types in an array.
If you know about how to create classes, this would be a place you could use a class with the three variables: 2 String and 1 int.
You'd create the object, store the values in it and save the object in an ArrayList.
Otherwise you will need another parallel array to hold the int counts.