In java i have an arrayList of my own(implemented) i have a sort method so i need 'compareTo' method thats why i implemented Comparable and made the class abstract. But if i use arraylist from main i have to implement compare to method .But I cant understand how i can implement this.( I have a restriction, for example if i have a arraylist of 'order' class i cant implement comparable in order class)
Arraylist
public abstract class ArrayList<T> implements Comparable
inside sort function
Comparable left=(Comparable)L[i];
Comparable right=(Comparable)R[j];
for(int k=start;k<=end;k++)
{
if(left.compareTo(right)<=0)
{
array[k]=L[i];
i++;
left=(Comparable)L[i];
}
From main
ArrayList<Order> order = new ArrayList<Order>() {
@Override
public int compareTo(Object o) {
if(this)// but this main is not order class this is arraylist class
return 0;
}
};