aspose file tools*
The moose likes Java in General and the fly likes Sorting algorithm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Sorting algorithm" Watch "Sorting algorithm" New topic
Author

Sorting algorithm

Gary Kit
Greenhorn

Joined: Aug 03, 2002
Posts: 7
Thanks for reading this message...
Any1 can provide me some algorithm about the various sortings in Java ?
eg: SelectionSort, BubbleSort and bla bla... : >

cheers
john guthrie
Ranch Hand

Joined: Aug 05, 2002
Posts: 124
Well, Arrays.sort(), according to the javadoc, uses quicksort.
The JDSL (http://www.jdsl.com/) seems to implement a few others.
Gary Kit
Greenhorn

Joined: Aug 03, 2002
Posts: 7
^_^ thx.. I have another question here
is it possible to pass arrays to other methods, or classes by reference or by value ?
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
Sure, you can pass arrays. You can pass an array of objects or primitives, as long as the type matches the method signature (and the method knows what to do with it).
For example, some method signatures:

In that last example (bar), you can legally pass any array since all arrays are Objects.

For your second question, the answer depends on how you want to look at it.
Some say that Objects in Java are passed by reference, and primitives (int, float, etc) are passed by value.
Others like to think that everything is passed by value, because what is really happening "in the guts of the JVM", is that you are passing the object reference by value.
Passing the object reference by value is like passing the object itself by reference.
In one sense, they are both right, as they both end up with the right behavior. It just depends on how you think about things. One of them will make more sense to you and help you to remember what is happening - that's probably the one you should use.
Gary Kit
Greenhorn

Joined: Aug 03, 2002
Posts: 7
thx very much~~
I begin to like this community : >
cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sorting algorithm