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

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -