import java.util.*; public class StackAndQueue { public static void main(String[] args) { Queue q = new LinkedList<>(); for(int i=0;i<5;i++) q.add(i); while(!q.isEmpty()) System.out.println(q.remove()); System.out.println(); Deque s = new LinkedList<>(); for(int i=0;i<5;i++) s.push(i); while(!s.isEmpty()) System.out.println(s.pop()); } }