Possible Duplicate:
Memory overhead of Java HashMap compared to ArrayList
I try to search on google but didnt found an answer, I need to store 160 entrys on a collection, and I dont want to iterate over them, I want to get the value by one entry, a point 2D, what is the best?
With less memory consume and faster access ?
Thanks alot in advance 😉
HashMap probably gives faster access. This could be computationally important, but only if the application does a huge number of lookups using the collection.
ArrayList probably gives least memory usage. However, for a single collection containing 160 elements, the difference is probably irrelevant.
My advice is to not spend a lot of time trying to decide which is best. Toss a coin if you need to, and then move on to more important problems. You only should be worrying about this kind of thing (where the collection is always small) if CPU and/or memory profiling tells you that this data structure is a critical bottleneck.