Java compiler error when trying to override superclass interface -


i don't understand why i'm getting compiler error when try , override push method below.

the exact output error in eclipse "name clash: method push(t) of type stackimplementation has same erasure push(object) of type stack not override it"

public interface stack<t> {     t pop();     void push(object t); }  public class stackimplementation<t> implements stack{      private final deque<t> deque = new arraydeque<t>();      @override     public t pop() {         return deque.removefirst();     }      @override     public void push(t t) {         deque.addfirst(t);     } } 

thank you!

you have 2 errors:

  1. push in interface uses object, should t:

    void push(t t);

  2. class implements stack, should stack<t>:

    class stackimplementation<t> implements stack<t> {


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -