• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

What is the capacity of a Map

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can i store as many as 20000 objects in a Map?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rohit Ahuja
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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???
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic