[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
Random non-repeating array  XML
Forum Index » Java Programming
Author Message
Lass88

Newbie

Joined: 07/20/2010 16:56:49
Messages: 2
Offline

For a homework assignment I have to write a program that takes 6 letters, puts them in an array and prints the letters in the array in a random order. For example I have [t, y, u, i, f, d] in my array and when I put it through my random method it will give me [y, d, t, u, f, i] or some other random order of these letters. I am also suppose print out all of the possible strings of these 6 letters exactly once and I am having a hard time figuring out how to do it. I figure that I am suppose to put it in a loop that compares the arrays it has already come up with to the new one to see if it is different and when it can't come up with a different array to exit the loop, but I have no idea how to write it. Any help is greatly appreciated, thanks!
stdunbar

Newbie
[Avatar]

Joined: 06/22/2005 14:51:37
Messages: 849
Location: Superior, CO, USA
Offline

What code do you have now? I'd think that you want one or more loops to do this. The hard part is keeping track of what has been already generated to make sure you don't generate it again.

Thanks for using the forums at hotjoe.com
[WWW] [Yahoo!] [ICQ]
Lass88

Newbie

Joined: 07/20/2010 16:56:49
Messages: 2
Offline

OK, this is my class:

import java.util.Random;




And this is my main:




The out put I get right now is [a, t, g, o, d, c] or some other one random version of the array.
 
Forum Index » Java Programming
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2011 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle