Java Collections (LIFO Structure)

前端 未结 6 1480
栀梦
栀梦 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 07:10

    I realize I'm late to the party here, but java.util.Collections (Java 7) has a static 'asLifoQueue' that takes a Deque argument and returns (obviously) a LIFO queue view of the deque. I'm not sure what version this was added.

    http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#asLifoQueue(java.util.Deque)

提交回复
热议问题