new LinkedList
new LinkedList<[type]>()
Queue<Integer> q = new LinkedList<>();
- add
- offer
add(E element)
offer(E element)
q.add(1);
q.add(2);
q.offer(3);
q.offer(4);
- poll
- remove
poll()
remove(E element)
// q: [1, 2, 3, 4]
q.poll(); //[2, 3, 4]
q.remove(4); //[2, 3]
- peek
- element
peek()
element()
// q: [2, 3]
System.out.println(q.peek());
System.out.println(q.element());
출력
2
2