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
author and iconoclast
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].
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.