Java Collections (LIFO Structure)

前端 未结 6 1481
栀梦
栀梦 2020-12-05 06:55

I am looking in the Collections framework of Java for a LIFO Structure (Stack) without any success. Basically I want a really simple stack; my perfect option would be a Dequ

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 07:14

    There's actually a Stack class: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Stack.html

    If you don't want to use that, the LinkedList class (http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList.html) has addFirst and addLast and removeFirst and removeLast methods, making it perfect for use as a stack or queue class.

提交回复
热议问题