问题描述
这可能是一个Java琐事问题。
我使用过实现多次。
我已经读到这被认为是一个遗留类,并且由于它的子类 Vector
坏在单线程应用程序。
我的问题是,Java Collection类中最好的替代方法是什么?
是否有另一个堆栈
类(可能有不同的名称)可供选择?
我的意思是,实现堆栈另一个现有的数据结构很容易,但我会期望有一个现有 Stack $ c $如果你读取更多的当前Javadoc(例如1.6或1.7),而不是旧的1.4。 2 docs,你会发现:
http://docs.oracle.com/javase/7/docs/api/java/util/Stack.html
This is kind of a Java trivia question perhaps.
I have used the Stack implementation many times.
I have read that this is considered a legacy class and due to the fact that it subclasses Vector
makes its performance bad in single threaded applications.
My question is, what is the best alternative among the Java Collection classes?
Is there another Stack
class available (by a different name perhaps) that is the one to choose?
I mean, ok implementing a stack arround another existing data structure is easy, but I would expect there is an existing Stack
to use.
If you read a more current Javadoc (1.6 or 1.7 for example) rather than the old 1.4.2 docs, you'll find:
http://docs.oracle.com/javase/6/docs/api/java/util/Stack.htmlhttp://docs.oracle.com/javase/7/docs/api/java/util/Stack.html
这篇关于使用Java Collections中的内容替换旧的堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!