wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Printing a sorted array 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 "Printing a sorted array" Watch "Printing a sorted array" New topic
Author

Printing a sorted array

James Palmer
Ranch Hand

Joined: Mar 15, 2004
Posts: 36
Hello, i have an array with 3 items in it and i want to print them in ascending order in a toString method.My code is:
public String toString() {
Arrays.sort(pile);
return "{" + (pile) + "}";
}
What do i need to change to this to get it working.Thanks
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Try this
 
Consider Paul's rocket mass heater.
 
subject: Printing a sorted array
 
Similar Threads
trouble with an array
Array of Objects to be passed into a method
Sorting arrays
a better way to convert List to array?
Differnce between new String(Byte[]) and byte[].toString()