File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Create string in random order. 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 "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: 11402
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create string in random order.