Start New Discussion within our Software Development Community

I have a generic class that contains a compareTo() method
I'm getting an error on the method it'self that goes something like;

Name clash: the method compareTo(T) of type twos<T N> has the same erasure as compareTo(T) of type Compareable<T> but does not override it.

How do I fix it?

here's my class

public class twos<P,N> implements Comparable<twos<P,N>>{
private P a;
private N b;
public twos(P puu, N paa ){
public P getP(){
return a;}
public N getN(){
return b;}
public compareTo(P bee){
int num1 = ((Comparable<twos<P, N>>) this.a).compareTo( (twos<P, N>) bee.b );
            if (num1 != 0)
                return num1;

            if (this.a < bee.a) return -1;
            if (this.a > bee.a) return 1;
            return 0;

}//end of class

Any help is appreciated

I believe my implemantation of the CompareTo method had the same letter as the original CompareTo method so I changed it in my method and this was fixed.

This question has already been answered. Start a new discussion instead.