Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

compareTo(Object) is undefined for Object

807607Nov 7 2006 — edited Nov 7 2006
I'm getting an error -The method compareTo(Object) is undefined for the type Object- with this code:
public static Object getMinimum (Object[] array)
{
   Object min = array[0];
   for (int i = 1; i < array.length; i++) {
      if (min.compareTo(array) > 0) {
min = array[i];
}
}
return min;
}

The objects in the array will always implement the Cloneable interface, but they can't use it, as they are treated as Object instances, not as instances of their own class. How can I fix this without using a Comparator?

Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 5 2006
Added on Nov 7 2006
8 comments
3,199 views