views:

160

answers:

3

Hmm. I'm noticing Stack is a subclass of Vector, and I thought Vector and Hashtable were considered "old" datastructures because of their builtin synchronization even if you don't need it. (vs. List, Map, etc. which don't provide it for you)

That and it's a class, not an interface.

Is there a more modern, recommended alternative?

+5  A: 

java.util.Deque

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.

John Kugelman
Collections.asLifoQueue will turn a `Deque` in to a "proper" LIFO queue.
Tom Hawtin - tackline
+2  A: 

Check out this post. http://stackoverflow.com/questions/302460/java-collections-lifo-structure

Jeff Storey
A: 

I ended up using LinkedList for my purposes (add() and removeLast() being push and pop operations). Oops, looks like this is a duplicate Q.

Jason S