-1

I'm trying to make an implementation of the Java queue class but I have some problems.

I want the class to implement the following interface:

 public interface iQueue<E> {
     public void add(E e); 
 }

 public class Queue<E> implements iQueue{

     Element<E> first;

     @Override
     public void add(E e) {
         Element<E> node = new Element();
         node.setData(e);
     }
 }

The compiler indicates that the add method parameter must be of type Object to implement the interface

If I declare the parameter of type Object, is the type E declared when constructing the class respected? Thank you very much

Alberto
  • 339
  • 4
  • 12

1 Answers1

1

You forgot the type parameter in the interface:

public class Queue<E> implements iQueue<E> { 
  //...
}

By the way, according to Java convention, your interface should start with upper case: IQueue<E>

Héctor
  • 24,444
  • 35
  • 132
  • 243