Queue in Java
Queue queue1 = new LinkedList(); Queue queue2 = new PriorityQueue(); class Test { public static void main(String[] args) { Queue<String> queue = new LinkedList(); queue.offer(“Steve”); queue.offer(“Megan”); queue.offer(“Ryan”); queue.offer(“Melissa”); System.out.println(queue); } } Output: [Steve, Megan, Ryan, Melissa] We can also use the add(Object o) method to add elements to the Queue. In this example, we will…
Read More Queue in Java