• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sorting NestedLoops

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the difference between these two blocks of code?
 
reply
    Bookmark Topic Watch Topic
  • New Topic