---
# System prepended metadata

title: stack vs queue
tags: [java]

---

# stack vs queue

###### tags: `java`


|                 |              stack               |                       queue                        |
|:---------------:|:--------------------------------:|:--------------------------------------------------:|
|    implement    |      Stack implement Vector      | LinkedList,ArrayList,PriorityQueue implement Queue |
|      InOut      |               FILO               |                        FIFO                        |
|      peek       | peek(),throw StackEmpty if empty |            peek(), return null if empty            |
| remove 1st node | pop(),throw StackEmpty if empty  |            poll(), return null if empty            |
|       add       |             add(el)              |                     offer(el)                      |