• Post Reply Bookmark Topic Watch Topic
  • New Topic

Numbering Array Items Numerically?  RSS feed

 
Matt Ilymore
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, so I tried implementing the bubble sort algorithm into my code, but now my output for the second array (in my code) is giving me a ton of zeros. Can anybody tell me what is wrong with my code and how I can fix it so the zeros are removed and the only thing that remains in the output for my second array are the fixed numerically?

The first array is the original list of items, and the second array is a copy of the first array, but numerically adjusted.

 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Matt and welcome to the Ranch! I see you've had a number of answers on another forum before you even posted here, so it would help if you tell us what you didn't understand of the advice given there.

Also, please BeForthrightWhenCrossPostingToOtherSites <- that's a link, click it to know why
 
Matt Ilymore
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. It was kind of confusing and they didn't really answer my questions back right away, so I thought I'd try a different forum... if that is okay.
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt Ilymore,

Your code is written in a very, how to easily say, messy way. Actually it is a simple code, but it looks the way more complicated than it actually is.
Not good enough code indentation, more than one empty lines appears in between actual code lines. Such a numbers as -9000, which doesn't say a lot about meaning of it - such a things make your code less readable.

Beside that - check line 38. Mistake appears over there.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And never close a Scanner or reader pointing to System.in.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!