• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Alphabetize a string. (again)

 
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic