HashMap vs LinkedHashMap

I've been evaluating HashMap vs LinkedHashMap and LinkedHashMap offers better performance and memory costs than HashMap.Does anybody know a reason to use HashMap against LinkedHashMap?
[199 byte] By [Remnahusha] at [2007-11-27 5:35:34]
# 1
You would use a HashMap if you didn't want the specific features of LinkedHashMap and the performance and memory costs associated with them.
DrClapa at 2007-7-12 15:04:48 > top of Java-index,Core,Core APIs...
# 2

According to the OP, I'd say his evaluation implies the opposite wrt. performance and costs. In my opinion, the evaluation failed, as it obviously has to be the other way around for average usage of instances. LinkedHashMap, in addition to a map, contains information about the order of elements. That is, more information (=more memory) and more effort to keep this information (=lower performance).

stefan.schulza at 2007-7-12 15:04:48 > top of Java-index,Core,Core APIs...
# 3

> According to the OP, I'd say his evaluation implies

> the opposite wrt. performance and costs.

Yes, that's what I thought too. I guessed it to be one of the sloppy micro-benchmarks you often see posted here.

> In my opinion, the evaluation failed, as it obviously has

> to be the other way around for average usage of

> instances.

That's why I ignored it and gave the answer I gave.

DrClapa at 2007-7-12 15:04:48 > top of Java-index,Core,Core APIs...
# 4
> That's why I ignored it and gave the answer I gave.Well, there was no "ignore"-Tag ;)I agree on the assumption it being a micro-benchmark.
stefan.schulza at 2007-7-12 15:04:48 > top of Java-index,Core,Core APIs...
# 5

Hi.

Please clarify what you mean by "LinkedHashMap offers better performance".

LinkedHashMap is just a standard hashmap, backed by a linked list. It's useful if you want to guarantee the order of the items in the map.

I imagine the "performance" of the two would be quite similar, but unless you need the ordering guarantes of LinkedHashMap you should probably use HashMap.

neilf79a at 2007-7-12 15:04:48 > top of Java-index,Core,Core APIs...
# 6
using hashmap doesn't ensure to retrieve the elements in same orderas they were inserted,but using linkedhashmap does ensures.
Yogesh.Nandwanaa at 2007-7-12 15:04:48 > top of Java-index,Core,Core APIs...