java实现栈-使用LinkedList
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(); } }