This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Permutations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Permutations" Watch "Permutations" New topic
Author

Permutations

Lin Shen
Ranch Hand

Joined: Oct 08, 2003
Posts: 57
Hello. I need to write a program which can do permutations. E.g
cat
cta
act
atc
tca
tac
will be printed out if the imput cat is given on the command line. Similarly, 24 different combinations should be printed out if a String with 4 characters are given.
The code I written is shown below:

The result I got missed first few characters for each combination. Could anyone help me to fix it? If you think my idea is totally wrong, please give me some hints, please.
Herb Schildt
Author
Ranch Hand

Joined: Oct 01, 2003
Posts: 239
I tried compiling the code that you posted but got a number of compiler errors. Could repost a clean copy of your program?


For my latest books on Java, including my Java Programming Cookbook, see HerbSchildt.com
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11170
    
  16

I couldn't get this code to compile without a few changes. even then, it wouldn't run - getting a "java.lang.NoClassDefFoundError: Permutations" error.
are you sure the code you posted was correct?
sorry for the duplicate post, i was typing mine when Herb posted his.
[ October 08, 2003: Message edited by: fred rosenberger ]

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Lin Shen
Ranch Hand

Joined: Oct 08, 2003
Posts: 57
Lin Shen
Ranch Hand

Joined: Oct 08, 2003
Posts: 57
Sorry. The copy/paste does not work. I therefore typed my code by hand. Here is the code again.
Lin Shen
Ranch Hand

Joined: Oct 08, 2003
Posts: 57
I have solved this problem!!! I am so happy now.
Herb Schildt
Author
Ranch Hand

Joined: Oct 01, 2003
Posts: 239
I am happy that your problem is fixed!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Permutations
 
Similar Threads
Garbage Collection question from K&B
Trying to create an arraylist of objects based on information from a text file
help with program
StringBuffer's setCharAt - near help
Need help with variables