基于案例的软件构造教程第三章解答
发布时间
阅读量:
阅读量
ADT stack
/** * 栈
* @param <T>
*/
public interface Stack<T> {
/** * 压栈
* @param t
*/
void push(T t);
/** * 出栈
* @return
*/
T pop();
/** * 获得栈顶元素
* @return
*/
T top();
}
//实现
public class StackWithArray<T> implements Stack<T> {
public StackWithArray() {
this(1); // 默认大小为 1
}
public StackWithArray(int size) {
this.top = -1;
this.size = si
全部评论 (0)
还没有任何评论哟~
