comparing generic types java, compareto override

79 Views Asked by At

i'm trying to run this but i can't compare that type with < or > it gets this error: The operator > is undefined for the argument type(s) T, T, anytips on how to fix it????????????????????????????

public class GenericElement<T extends Comparable<T>> implements Comparable<GenericElement<T>>

{

private GenericElement next;
private T value; 

public GenericElement(T value, GenericElement next) {
    this.value = value;
    this.next = next;
}

public GenericElement getNext() {   
    return next;
}

public void setNext(GenericElement next) {
    this.next = next;
}

public T getValue() {
    return value;
}

public void setValue(T value) {
    this.value = value;
}


@Override
public int compareTo(GenericElement<T> o) {
    // TODO Auto-generated method stub
    if(o.getValue()>this.getValue()) //i get error here The operator > is undefined for the argument type(s) T, T {
        return -1;
    }
    else if(o.getValue()==this.getValue()) {
        return 0;
    }
    else {
        return 1;
    }
}

}

0

There are 0 best solutions below