Stacks and Queues
Chapter8: Using Edge, Mail, And People
Section: Chapter Questions
Problem 8QY
Related questions
Question
Stacks and Queues
![](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9421e723-3e78-4aa4-87ea-4bbe8b7f405d%2F9895d3f7-a746-4e41-a9d3-701c335ff7be%2Fi6vqhoo.jpeg&w=3840&q=75)
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
Step 1:
The given code will result in error as the Queue interface is implemented using ArrayDeque class not ArrayQueue Class.
The output provided in this answer is after the correction in code.
Corrected Code:
import java.util.*;
public class HelloWorld{
public static void main(String []args){
System.out.println("Hello World");
Queue<Integer> q = new ArrayDeque<Integer>();
for(int i=2;i<10;i+=2)
q.add(i);
while(!q.isEmpty())
System.out.println(q.remove()+" ");
}
}
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you