为什么集合框架中没有堆栈接口?
Why there is no stack interface in the collection framework?
为什么java中的集合框架没有栈接口?
Java 集合框架提供了许多接口(Set、List、Queue、Deque)和类(ArrayList、Vector、LinkedList、PriorityQueue、HashSet、LinkedHashSet、TreeSet)。那么,为什么不使用堆栈接口呢?
Stack
是遗产 class。 Deque
接口及其实现提供了一组更完整和一致的 LIFO 堆栈操作。
来自 java-doc、
Deques can also be used as LIFO (Last-In-First-Out) stacks. This
interface should be used in preference to the legacy Stack class
Stack
class图表,
我认为因为已经有一个 java.util.Stack class,所以他们无法在不引起很多混乱的情况下添加堆栈接口。
为什么java中的集合框架没有栈接口? Java 集合框架提供了许多接口(Set、List、Queue、Deque)和类(ArrayList、Vector、LinkedList、PriorityQueue、HashSet、LinkedHashSet、TreeSet)。那么,为什么不使用堆栈接口呢?
Stack
是遗产 class。 Deque
接口及其实现提供了一组更完整和一致的 LIFO 堆栈操作。
来自 java-doc、
Deques can also be used as LIFO (Last-In-First-Out) stacks. This interface should be used in preference to the legacy Stack class
Stack
class图表,
我认为因为已经有一个 java.util.Stack class,所以他们无法在不引起很多混乱的情况下添加堆栈接口。