aspose file tools*
The moose likes Beginning Java and the fly likes Alphabetize a string. (again) 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 "Alphabetize a string. (again)" Watch "Alphabetize a string. (again)" New topic
Author

Alphabetize a string. (again)

Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
This is a post in response to This one about alphabetising a String. The code in the original post of this thread was modified, so now I'm commenting on the changes. I'm doing this rather than adding to the original thread because on the original thread code changes were made after comments were added. This makes the thread a little nonsensical.
So, here goes:

Hi Kathy,
The code you put up is really really close to working, so I'll go against my usual principle of not correcting code outright, and do just that. Here's your code with a few changes:

OK, so I made these changes:
At 1, I did two things:. First, removed the extra parameter to showMessageDialog that wasn't needed (and would have caused a compilation error). Second, I replaced 'charArray' with 'sort(s)'. I hope it's clear why I did this - we have the sort method, and we want to print the result of sorting the String s.
At 2 and 3, I changed 'string' to 's'. Your method sort takes a parameter of type String, whose name is 's'. So, when you want to access that parameter, you use the name 's'.
One final point is that you could do this in an easier way. The body of your sort method could be replaced by the following:

Hope all this helps, if anything's unclear, post back.
Cheers
--Tim

PS I tried to send you a private message about this but it says you're not accepting them. Also, looks like no-one gets told when a post is modified. So I'm guessing it's best to re-post and give a reference (or even a link) to your previous post.
[ April 21, 2004: Message edited by: Tim West ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Alphabetize a string. (again)