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:
push in interface uses
object
, shouldt
:void push(t t);
class implements
stack
, shouldstack<t>
:class stackimplementation<t> implements stack<t> {
Comments
Post a Comment