I have created a code to accept 10 integers into a stack and a queue and then print the output simultaneously removing items from both.
I can enter the inputs for both stack and queue, but there is no output shown.
Why is this and how can I resolve it?
Below is the code :
import javax.swing.*;
import static javax.swing.JOptionPane.*;
public class StacknQueue {
public static void main(String args[]){
StackArrayBased stack = new StackArrayBased();
QueueArrayBased queue = new QueueArrayBased();
for(int i=0; i<11; i++){
stack.push(showInputDialog("Enter an integer into Stack :"));
queue.enqueue(showInputDialog("Enter an integer into Queue : "));
}
System.out.println("\n Numbers stored in Stack \n");
while((!stack.isEmpty())){
System.out.println((String)stack.pop());
}
System.out.println("\n Numbers stored in Queue \n");
while((!queue.isEmpty())){
System.out.println((String)queue.dequeue());
}
}
}