This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Sure you can. The capacity is only limited by the amount of memory available to JVM. And though only references are stored in the map, the objects exist on the heap. So, the number of objects you can store depends on how much memory each object is consuming.
Originally posted by Deepak A: Michael, I know how to use the Map interface but what i am worried about is whether it is a good idea to store 20000 elements in a Map???
You didn't ask if it was a good idea, though -- you asked if you can. Different question! But the answer is the same: yes, pretty much. 20,000 is a small number as far as any of the standard API map implementations go.
On another note, you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. An initial isn't enough for a last name. You can change your display name here. Thanks! We take this rule rather seriously.
If it's a good idea to store 20,000 items in a map, that depends on what you're storing in the map. If you're just storing relatively small objects, it's not a problem. If you're storing large objects, you could get out of memory problems.