• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create string in random order.

 
Shirley Flood
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12083
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic