I have an interface, and when I try to implement one of its methods, I get this error :
"name clash: enqueue(T#1) in GenericQueue and enqueue(T#2) in IGenericQueue have the same erasure, yet neither overrides the other where T#1 ,T#2 are type variables:
T#1 extends Comparable declared in class GenericQueue
T#2 extends Comparable declared in interface IGenericQueue "
here's the code :
public interface IGenericQueue <T extends Comparable> {
public void enqueue(T j);
..
}
public class GenericQueue<T extends Comparable> implements IGenericQueue {
....
public void enqueue(T j) // the error is in this line.
{
if(rear == maxSize -1)
rear = -1; // means you have reached the last element start again ?
queArray[++rear] = j;
nItems ++ ;
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…