JAVA泛型队列继承泛型栈要如何操作?

import java.util.Stack;
import java.util.NoSuchElementException;
public class Queue extends Stack{
public final int dump=1024;
private Stack stk;
public Queue( ){ /* 在此插入代码*/ }
public boolean add(E e) throws IllegalStateException, ClassCastException,
NullPointerException, IllegalArgumentException{ /* 在此插入代码*/ }
public boolean offer(E e) throws ClassCastException, NullPointerException,
IllegalArgumentException{ /* 在此插入代码*/ }
public E remove( ) throws NoSuchElementException { /* 在此插入代码*/ }
public E poll( ) { /* 在此插入代码*/ }
public E peek ( ) { /* 在此插入代码*/ }
public E element( ) throws NoSuchElementException { /* 在此插入代码*/ }
}
填充这几个函数

 public Queue( ){ stk = new stk(); }
public boolean add(E e) throws IllegalStateException, ClassCastException, 
NullPointerException, IllegalArgumentException{ this.push(e); }
public boolean offer(E e) throws ClassCastException, NullPointerException, 
IllegalArgumentException{ return this.size() > 0; }
public E remove( ) throws NoSuchElementException { return this.pop(); }
public E pull( ) { while ( E e = this.pop()) this.stk.push(e);
E r = e;
while ( E e =stk.pop()) this.push(e);
return r;
}
public E peek ( ) { return this.peek(); }
public E element( ) throws NoSuchElementException {
throws new NoSuchElementException (); //这个不需要实现
}

可以参考:
https://www.cnblogs.com/gleesu/p/6751322.html
https://blog.csdn.net/scgaliguodong123_/article/details/48175183

 public class Queue<E> extends Stack<E>{
    public final int dump=1024;
    private Stack<E> stk;
    public Queue( ){ stk = new Stack<E>();  }

    public boolean add(E e) throws IllegalStateException, ClassCastException, 
    NullPointerException, IllegalArgumentException{ stk.push(e); return true;    }

    public boolean offer(E e) throws ClassCastException, NullPointerException, 
    IllegalArgumentException { return this.add(e); }

    public E remove() throws NoSuchElementException {  synchronized(this) {
            if (!this.isEmpty()) { return super.pop(); } else {  while(!stk.isEmpty()) this.push(stk.pop()); return super.pop(); }  }
    }

    public E poll( ) { return this.remove();  }

    public E peek ( ) {
        synchronized(this) { if (!this.isEmpty()) { return super.peek(); } else { while(!stk.isEmpty()) super.push(stk.pop()); return super.peek();  } }
    }

    public E element( ) throws NoSuchElementException {  throws new NoSuchElementException (); //这个不需要实现 }
}