I'm trying to compare the values within my nodes with the Comparable
interface. But when implementing the method compareTo
I get an error: It says that the operator can not be applied to <E>
(which is my generic value).
I leave you code:
public class LEGultimoEC<E> extends LEGultimo<E> implements Comparable<NodoLEG<E>> {
public LEGultimoEC(NodoLEG<E> primero, NodoLEG<E> ultimo) {
super();
}
@Override
public int compareTo(NodoLEG<E> o) {
int resultado = 0;
if(o.getDato()<o.getSiguiente().getDato()){
return -1;
}else if(o.getDato()>o.getSiguiente().getDato()){
return 1;
}
}
}
The value in data is int
.