File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Sorting NestedLoops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Sorting NestedLoops" Watch "Sorting NestedLoops" New topic

Sorting NestedLoops

Roderic Lowe

Joined: Nov 27, 2004
Posts: 1
I have been working on this program for nearly a day now and I have had no luck getting it to work. Can anyone give me the answer informing me where my mistake lies within the program. The program is suppose to sort the list of numbers in asending order counting each loop as the process (list) is completed. Here is the program:
[ edited to format code and to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ November 27, 2004: Message edited by: Dirk Schreckmann ]
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Dirk may post ahead of this, but here are a few hints:
1. The j loop should go from i to 1 less than the highest array index.
2. You only need the first if statement.
3. The block controlled by the if statement has the braces {} in the wrong places.

The good news is that you have the right idea.

Mike Gershman
SCJP 1.4, SCWCD in process
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Roderic!

What happens when you try to compile your code? Do any error messages get printed? What are they?

If you're getting a lot of error messages, I'd recommend trying to solve the first one first, recompiling, and then handling the first of any new problems that arise.

If you're not quite sure what an error message means or how to solve it, post it here, along with the problem code, and I'm sure folks will be glad to help nudge you in the right direction.

When I program, in general, I do everything in baby steps. For example, I don't write a line of code without first knowing that every existing line compiles without errors. That way, when a compiler error does occur, I know where it is, and I'm not trying to understand and solve a handful of problems all at once, since that one line of code generally doesn't have more than one or two problems.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
What's the difference between these two blocks of code?
I agree. Here's the link:
subject: Sorting NestedLoops
It's not a secret anymore!