the method compareTo(Object) is undefined for the type Object
807598Sep 25 2006 — edited Sep 25 2006im getting an error "the method compareTo(Object) is undefined for the type Object". can anyone help??
public Comparable find(Comparable anObject)
{
for(int index = 0; index < data.size(); index++)
{
Object temp = new Object();
Object comp = data.get(index); //get an object to compare with
int n = anObject.compareTo(comp);
if(n == 0)
{
currentElement = index;
return (Comparable)comp;
}
else if(n>0)
{
int p = temp.compareTo(comp); //here is the ERROR
temp = comp;
if(p == 0)
{
currentElement = index;
}
else if(p<0)
{
currentElement = index;
return (Comparable)temp;
}
else
{
temp = comp;
currentElement = index;
}
}
}
}