Question: I have a object in java called foo.
I can do `foo.getDate();` and that will give me the date of one item.
But now I have a `list<foo>` and I want to get per item one date.
So if I loop through my list I will see this output:

```
3-1-2015
3-1-2015
5-1-2015
8-1-2015
8-1-2015

```

But I want to see:

```
3-1-2015
5-1-2015
8-1-2015

```

So I want that only the first item with a unique date will be added to the list.
How can I do this in Java? 

Thanks in advance!

Answer: 
Probably the most easy way would be use a map (`HashMap` for example)... Use the Date as a key, then put all your Foo objects into it. Then every time a key already exists the value will be overwritten and you'll end up with only one Foo object per Date. If you need a list (for sorting, for example) you can do something like `new ArrayList<Foo>( myMap.values() );` then.
well you probably should use `Set` for this.