A queue is a linear list in which items are added at one end and deleted from the other end. Familiar examples are queues at a bank, a supermarket, a concert, or a sporting event. People are supposed to join the queue at the rear and exit from the front.
- [Instructor] Queues are another example…of data structure in Java.…A queue is a linear list in which items are added at one end…and deleted from the other end.…Familiar examples are queues at a bank,…at a supermarket, a concert, or a sporting event.…People are suppose to join the queue at the rear,…and exit from the front.…We would expect that a queue data structure would be useful…for a simulating these real-life queues.…Another type of queue is a print queue.…
When you print jobs on your computer,…they go into a print queue,…and they wait for their printer to be available,…and then they execute it in the order…in which they were received.…The methods for a print queue include add,…which is used to add elements to the end of the list.…Peek, which returns a copy of the first element.…Remove removes the first or top element,…and returns an error if it's empty.…And poll is a new method that removes from the top,…but this one returns null if the queue is empty…instead of an error.…
Let's switch to NetBeans,…and take a look at how to use a queue in a program.…
In this course, explore data structures in the Java language. Follow Peggy Fisher as she introduces you to several types of commonly-used data structures in Java. Peggy explores ArrayLists and LinkedLists, both of which implement the List interface, which extends the Collection interface and allows you to access list elements in a specific order. She also goes into the Vector, Stack, and Queue collection classes. To help you better understand these new concepts, Peggy wraps up the course with a challenge—creating a grocery list—and provides a solution for that challenge.
- Reviewing the types of data structures
- Working with the Collection interface and Iterable interface
- Working with ArrayLists and LinkedLists
- Using the Vector, Stack, and Queue collection classes