From the course: Nail Your Java Interview
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Using queues in technical interviews - Java Tutorial
From the course: Nail Your Java Interview
Using queues in technical interviews
- [Instructor] A queue represents an ordered list of objects, just like a list, but its intended use is slightly different. A queue is designed to have elements inserted at the end of the queue, and elements are removed from the beginning of the queue. If you think of a line at a supermarket, the first person in line is always the first person out of line. The last person that joins the line is also the last person out of line. To use queues in Java, we have the java.util.Queue interface. Since an interface is not concrete, we'll need to instantiate an implementation of the interface in order to use it. In Java, we can choose between a linked list and a priority queue. A linked list is a pretty standard queue implementation, so we're going to use this implementation in our example. Let's take a look at how this works in code. Here, we have an example where we want to process the requests of a series of people in line in…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.