Save
Java part 2
Queues
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Ruby
Visit profile
Cards (4)
Queue
object creation
FIFO: first in, first out data structure
import java.util.LinkedList;
import java.util.Queue;
Queue<String> printerQueue = new LinkedList<String>();
.offer()
method

add an element to the back of the queue
.poll()
method
return null if the queue is empty
retrieves and removes an element
from the front of the queue
.peek()
method
returns null if the queue is empty
retrieves but does not remove
the element at the front of the queue