English
Looping through list of words I call a function that returns a HashSet of movie titles that contain that particular word. I want to insert these titles into a HashMap with their value being a counter of how many times this title occured.
(if two words return the same title, that title's value (counter) would be 2)
Relative Code:
Expand|Select|Wrap|Line Numbers
- for(int i = 0; i < titleWords.length; i++ ) {
- HashSet tempHash = (HashSet) hashtable.get( titleWords[i] );
- // put result into hashmap and increment counter
- Iterator myIt = tempHash.iterator();
- int counter;
- while(myIt.hasNext()) {
- counter = 0;
- String title = (String) myIt.next();
- counter = (int) resultMap.get((String)myIt.next()); //*** ERROR: inconvertible types
- resultMap.put((String)myIt.next(), ++counter);
- }
- }
Since I can't sort a HashMap, would something else work better? if so, don't bother answering my question with a HashMap, answer it with another list/array implementor that can store key/value pairs.
Thanks for any pointers,
Dan