Best way to count items in lists

I have two lists of strings. I would like to tally the number of occurances of each string in the lists. Would the best way to do this be through associative arrays? If so, how...
[186 byte] By [mateobusa] at [2007-10-3 4:55:52]
# 1
Could you maybe hint as to what the method signature would be?
cotton.ma at 2007-7-14 23:01:04 > top of Java-index,Java Essentials,Java Programming...
# 2

Yeah, use associative arrays, or in java talk: java.util.Map. (This would be so easy in Perl, but anyway.) Basically, loop through each list, and create or modify entries in the map where the key is the string and the value is the current count of occurances of each string.

Then just loop through the keys of the map (you can sort them first using java.util.Collections.sort, if you like) and print the key and the corresponding value in the map.

If you're using JDK1.5, it's even easier, what with the new for loops and autoboxing and whatnot.

paulcwa at 2007-7-14 23:01:04 > top of Java-index,Java Essentials,Java Programming...