Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
Beginning Java
How to sort String, for example: abced. to change to abcde
sandeeps srivastava
,
Greenhorn
Aug 22, 2008 05:43:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
hi ,
i am beginners in
java
, i have proble to sorting a
string
for example how we sort abecd into abcde in java
please help
Amit Ghorpade
,
Bartender
staff
Aug 22, 2008 05:57:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Let us know how far have you gone with the problem.
Hint:You can use the charAt() method and any sorting mechanism you wish to implement.
Piet Verdriet
,
Ranch Hand
Aug 22, 2008 05:58:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
1 - create an array of characters from String X;
2 - sort the character array;
3 - create a new String from the sorted array;
4 - reassign X to the newly created String;
5 - have a beer... err... cup of
coffee
!
Have a look at the String- and Arrays API docs for steps 1, 2 and 3:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Arrays.html
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
fred rosenberger
,
lowercase baba
staff
Aug 22, 2008 05:59:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Is this a homework assignment? What have you tried? are you allowed to use all the tools in the api, or do you have to write your own sort?
I'd strongly recommend you read our
FAQ
to get the most out of the JavaRanch.
Post by:
autobot
Have you no shame? Have you no decency? Have you no tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 1383 times.
Similar Threads
References in JAVA
is there a sizeof() in Java?
Refering variables of class which extends applet
Passed SCJP 1.2
Java String pool problem
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:34:47
.