aspose file tools*
The moose likes Java in General and the fly likes comparable question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "comparable question" Watch "comparable question" New topic
Author

comparable question

Everett Chan
Greenhorn

Joined: Sep 15, 2005
Posts: 3
Hi, I am seeking for help on a Comparable question, if anybody can provide any insight I'd greatly appreciate it.

I have an int array and a method that takes in (Comparable[] array), what could I do to make the Comparable[] accepts the int array? Do I have to change the int array to an array of Integer Objects? Or is there another way I can tackle this?

Thank you very much,
Everett Chan
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi Everett,

Welcome to JavaRanch!

On the face of it, yes, making an array of Integer could be one easy solution. Alternatively, you could make a copy of that method that takes an array of Comparable, and modify it to work with ints. If c is an array of Comparable and i is an array of ints, then c[n].compareTo(c[m]) translates directly into i[n] - i[m].


[Jess in Action][AskingGoodQuestions]
Everett Chan
Greenhorn

Joined: Sep 15, 2005
Posts: 3
Thank you very much.

What is this forum's policy on someone posting a segment of their code to ask for help?

e.g. me posting my reverse int array and asking for help to turn them into Integer Object-based.

Thank you for all the help,
Everett
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

You're welcome to post code. We appreciate it if you keep the code as short as possible -- i.e., don't post code for a GUI with 100 buttons if you're asking about JDBC -- and if you use the UBB [C0DE][/C0DE] tags to surround the code to preserve the formatting.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: comparable question