wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Randomize a set of words Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Randomize a set of words" Watch "Randomize a set of words" New topic
Author

Randomize a set of words

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Hi. Not sure if this is the right place to post this. We are trying to create a table that has a ton of four letter words in it(minus the nasty ones ). Right now we have the list of words in an Excel spreadsheet in alphabetical order. We want to scramble these so when we use them to be assigned as order codes, they don't get assigned alphabetically. My question is, how do I do this? Can anyone supply me with some java code to get this done, or at least give me a couple of hints where to look?
Thanks in advance!!
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1751
    
    2
Take a look at Collections.shuffle() to see it can help you out.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
You can try something like this

This will return the String[] in a completely random order.
[ April 08, 2002: Message edited by: Carl Trusiak ]

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Thanks guys!!
 
 
subject: Randomize a set of words