Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the best/most efficient Java collection to use to pull a random value?

I am creating an NPC generator, in which all their attributes are randomly pulled from their respective collection of possible values. What would be the most efficient collection to use to store the possible values in order to randomly pull a value from or is there no real difference?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

An ArrayList gives you the best performance for randomly choose a value because it has O(1) access time.

See here for a explanation: https://stackoverflow.com/a/322742/7142748

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading