This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Create string in random order. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Create string in random order." Watch "Create string in random order." New topic
Author

Create string in random order.

Shirley Flood
Greenhorn

Joined: Mar 25, 2008
Posts: 4
String text = "Work at Home";
I need to write the code that will create a new string the same length, and contain each character of the original string in random order.

class Stringrandom {

public static void main(String[] arguments) {
String str = "Work at Home";
System.out.println("The random string is: " + str.random());
}

}
[ March 27, 2008: Message edited by: Shirley Flood ]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

First, welcome to the Ranch!!!

Second, we're happy to help. But you need to show us what you've done, and tell us where you're stuck. We can point you in a direction, but you're gonna have to do most of the work yourself.


Never ascribe to malice that which can be adequately explained by stupidity.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

Pesudo code:

Now for some hints:
- use StringBuilder (Java 5 or up) or StringBuffer (Java 1.4 and down) for random and orig
- use java.util.Random for getting the random index


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Create string in random order.
 
Similar Threads
guessing game
Constructor with Exception
How to make a JNLP file take dynamic parameter
Inorder traversal of a Binary Search Tree
print out random number and state odd/even