This content has been marked as final. Show 1 reply
There are "standard" ways of tackling this - including the one used in Sun's
Collections.shuffle() method. But I guess the value of this exercise lies in
working out some algorithm of your own.
It might help to know that you can convert a string into an array of char values.
This creates an array consisting of the the chars 'a', 'b', 'c', 'd', 'e'.
String test = "abcde"; char arr = test.toCharArray();
Before you can use this in any meaningful way you need to imagine the
letters in front of you. It might help to imagine the letters each being in a
numbered position (like they are in an array). Think, and write down, how
you would go about making a random word using all the letters. You can
assume you have dice or some other source of random numbers available.
Once you have something definite in plain English (or whatever language
you're most comfortable in), then have a go at writing the code in Java.