Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I randomly pick any ArrayList index?

807603Feb 10 2008 — edited Feb 10 2008
Hi,

My problem is that, I have an ArrayList with a number of entries in.. Each iteration that this ArrayList is read the ArrayList index should decrease by 1.

What I am trying to do though is randomly select an index within the ArrayList to get a value from.

Would I use Java's random function to generate a random number according to the size of the ArrayList.

Thus given me a random index..?

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 9 2008
Added on Feb 10 2008
6 comments
197 views