// short program to demonstrate basic use of a stack and queue import java.util.*; public class SimpleStackQueue { public static void main(String[] args) { String[] data = {"may", "the", "force", "be", "with", "you"}; Queue q = new LinkedList<>(); Stack s = new Stack<>(); for (int i = 0; i < data.length; i++) { q.add(data[i]); s.push(data[i]); } System.out.println("initial queue = " + q); while (!q.isEmpty()) { String str = q.remove(); System.out.println("removing " + str + ", now queue = " + q); } System.out.println(); System.out.println("initial stack = " + s); while (!s.isEmpty()) { String str = s.pop(); System.out.println("removing " + str + ", now stack = " + s); } } }