File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Putting Ints into an Object array. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Putting Ints into an Object array." Watch "Putting Ints into an Object array." New topic
Author

Putting Ints into an Object array.

Adam Ellsworth
Greenhorn

Joined: Sep 25, 2004
Posts: 21
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

Joined: Jul 30, 2003
Posts: 804
Integer objects would fit the bill...


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Adam Ellsworth
Greenhorn

Joined: Sep 25, 2004
Posts: 21
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

Joined: Jul 30, 2003
Posts: 804
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Putting Ints into an Object array.
 
Similar Threads
Array in reverse order......?
Comparing values
swapping the data
help with sort code
Does arraycopy create aliases?