File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Sorting algorithm" Watch "Sorting algorithm" New topic

Sorting algorithm

Gary Kit

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... : >

john guthrie
Ranch Hand

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

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

Joined: Aug 03, 2002
Posts: 7
thx very much~~
I begin to like this community : >
I agree. Here's the link:
subject: Sorting algorithm
Similar Threads
Glory Gloory Man United
Regular Expressions in String.split()
WA #1.....word association
How can I get code examples to look right
choices.txt size