发布网友 发布时间:2022-04-27 07:41
共1个回答
热心网友 时间:2022-06-28 16:12
import java.util.LinkedList;
public class LinkedListStack {
public static void main(String[] args) {
myStack stack = new myStack();
for (int i = 0; i < 10; i++){
stack.push(i);
}
System.out.println(stack.top());
System.out.println(stack.top());
}
}
class myStack extends LinkedList{
public void push(Object v){
this.addLast(v);
}
public Object pop(){
return this.removeFirst();
}
public Object top(){
return this.getFirst();
}
}
// 抄的, 其实这家伙挺懒
// 建议你上百度搜
参考资料:http://blog.csdn.net/gxzheng1985/archive/2007/06/20/16591.aspx