File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Putting Ints into an Object array.

 
Adam Ellsworth
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a program to compare the effiecency between heapsort and bubblesort. We were givin the code for both of the sorts and have to use them. The only problem is the code contains Object arrays and I'm not sure how to put integers (we have to make the arrays for testing) into the Object array coding. I created the integer arrays by using a simple for loop with a random number generator which works fine. Any help to tell me how to put ints into Object arrays would be appreciated. Here is the heapsort algorithm we were given that we have to use:



Here is how I am creating my random integer array:

 
Jeff Bosch
Ranch Hand
Posts: 805
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer objects would fit the bill...
 
Adam Ellsworth
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, just figured that out, hehe. But now the algorithm he gave us isnt doin much

here's the code he gave us. I'm sure i'm doing something wrong opposed to his code being wrong.

 
Jeff Bosch
Ranch Hand
Posts: 805
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest starting with adding some debug print statements so you can compare what you think the program should be doing at several points compared to what the program really is doing at those points. For example, where the code is assigning a value, for example:


You could add a print statement to see what really is being assigned to temp:


[ February 09, 2005: Message edited by: Jeff Bosch ]
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic