用 LinkedList 实现一个 java.util.Stack 栈 import java.util.LinkedList; public class Stack<E> { private LinkedList<E> storage = new LinkedList<>(); public E push(E e) { storage.addFirst(e); return e; } public E peek() { return storage.getFirst(…
查看java的API文档,Stack继承Vector类. 栈的特点是后进先出. API中Stack自身的方法不多,基本跟栈的特点有关. import java.util.Stack; public class StackTest { public static void main(String[] args) { Stack<String> stack = new Stack<String>(); System.out.println("now the stack is …
接上篇“java集合类(五)About Map” 终于来到了java集合类的尾声,太兴奋了,不是因为可以休息一阵了,而是因为又到了开启新知识的时刻,大家一起加油打气!!Come on...Fighting! About “interface Queue<E>” All Superinterfaces:Collection<E>, Iterable<E> All Known Subinterfaces:BlockingDeque<E>, BlockingQue…