Help with a Collection

Hi,I have a Collection of objects and I want to somehow output each the name of each object and how many times it occurs in the Collection.Any ideas? Sorry I can't really explain it better.
[211 byte] By [giggipa] at [2007-11-27 1:02:39]
# 1
What type of collection do you have?
kajbja at 2007-7-11 23:37:39 > top of Java-index,Java Essentials,Java Programming...
# 2
It is a Collection of items ( a custom class).The Collection is just declared as a Colection.
giggipa at 2007-7-11 23:37:39 > top of Java-index,Java Essentials,Java Programming...
# 3

What's a name of an object? You are pretty vague? Why can't you be more specific?

Create a map

Iterate over the collection, get the name of each object, check if it exists in the map. Add it to the map if it doesn't exist, use the name as key and a counter as value. Just increase the counter if it exists.

Kaj

kajbja at 2007-7-11 23:37:39 > top of Java-index,Java Essentials,Java Programming...
# 4
Ah, nice idea, thanks.Once you have everything in a Map though, how would you iterate through?Thanks!
giggipa at 2007-7-11 23:37:39 > top of Java-index,Java Essentials,Java Programming...
# 5
Get the entry set from the map, iterate over it and print all entries.Kaj
kajbja at 2007-7-11 23:37:39 > top of Java-index,Java Essentials,Java Programming...
# 6
Ah okay, I'll try that.Thanks alot for your help, much appreciated!
giggipa at 2007-7-11 23:37:39 > top of Java-index,Java Essentials,Java Programming...