Sorting Numbers in Java

I REALLY NEED HELP

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 13930 Views - Last Post: 23 February 2009 - 07:21 AM Rate Topic: -----

#16 barsoum89  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 20-February 09

Re: Sorting Numbers in Java

Posted 23 February 2009 - 07:21 AM

View PostDelta62, on 23 Feb, 2009 - 02:10 AM, said:

The problem here is a simple one...

The code that you have declares an int someInt:
double someInt;

At this point, there is no value associated with the variable someInt, though. Just a data type. So when you use this statement:
myArray[4] = someInt;

There is nothing to assign to myArray[4].
Actually, this is fine because myArray only has 4 values (remember that in Java, numbers start at 0 when incrementing, so myArray[4] is actually a fifth element in the list).
That being said, you should be able to delete this line entirely:
myArray[4] = someInt;

to display the numbers once the sorting algorithm is done, try using another showMessageDialog command, but pass the objects from the list to it:
JOptionPane.showMessageDialog(null, myArray[0] + " " + myArray[1] + " " + myArray[2] + " " + myArray[3]);



once again thank you all so much for your help it works perfectly!!!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2