Omo Jesu wrote:I have done that but I am no just getting it.
So exactly what is it that you're having trouble with?
HashMap relies on the results of the
equals() and
hashCode() methods for the class you use as a key, so if you intend using
Game (and I assume its
Game and not
Games) and
Store as your keys, you'd better get those methods correct; otherwise you'll run into problems.
A TreeMap, on the other hand, can take a Comparator, so you can order those pretty much any way you want.
Another tip: If this Map is going to be used for stockkeeping, I'd use AtomicInteger rather than Integer, because you can change the value. With an Integer you'll have to replace it every time to want to change the value.
Winston