// Simple program showing the use of a stack and queue. import java.util.*; public class StackQueue1 { public static void main(String[] args) { Queue q = new LinkedList(); Stack s = new Stack(); String[] data = {"four", "score", "and", "seven", "years", "ago"}; for (String str : data) { s.push(str); q.add(str); } System.out.println("stack = " + s); while (!s.isEmpty()) System.out.println(s.pop()); System.out.println("queue = " + q); while (!q.isEmpty()) System.out.println(q.remove()); } }