嗯。我注意到 Stack 是 Vector 的一个子类,我认为 Vector 和 Hashtable 被认为是“旧”数据结构,因为它们具有内置同步功能,即使您不需要它也是如此。 (与不为您提供的列表、 map 等相比)
那是一个类,而不是一个接口(interface)。
是否有更现代的推荐替代方案?
最佳答案
Deques can also be used as LIFO (Last-In-First-Out) stacks. This interface should be used in preference to the legacy Stack class. When a deque is used as a stack, elements are pushed and popped from the beginning of the deque.
关于java.util.Stack 合适的数据结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1320217/