@@ -0,0 +1,1084 @@
+package com.matao.extra;%0A%0Aimport java.util.EmptyStackException;%0Aimport java.util.LinkedList;%0Aimport java.util.Queue;%0A%0A/**%0A * Created by matao on 2018-12-07.%0A * %3Cp%3E%0A * %E7%94%A8%E4%B8%A4%E4%B8%AA%E9%98%9F%E5%88%97%EF%BC%8C%E5%AE%9E%E7%8E%B0%E6%A0%88%E7%9A%84 push %E5%92%8C pop%0A */%0A@SuppressWarnings(%22Duplicates%22)%0Apublic class StackWith2Queues%3CE%3E %7B%0A%0A    private Queue%3CE%3E queue1 = new LinkedList%3C%3E();%0A    private Queue%3CE%3E queue2 = new LinkedList%3C%3E();%0A%0A    public void push(E item) %7B%0A        if (!queue2.isEmpty()) %7B%0A            queue2.offer(item);%0A        %7D else %7B%0A            queue1.offer(item);%0A        %7D%0A    %7D%0A%0A    public E pop() %7B%0A        if (!queue2.isEmpty()) %7B%0A            int size = queue2.size();%0A            // %E4%BF%9D%E7%95%99%E6%9C%80%E5%90%8E%E5%85%A5%E9%98%9F%E7%9A%84%E5%85%83%E7%B4%A0%0A            for (int i = 0; i %3C size - 1; i++) %7B%0A                queue1.offer(queue2.poll());%0A            %7D%0A            return queue2.poll();%0A        %7D else if (!queue1.isEmpty()) %7B%0A            int size = queue1.size();%0A            for (int i = 0; i %3C size - 1; i++) %7B%0A                queue2.offer(queue1.poll());%0A            %7D%0A            return queue1.poll();%0A        %7D else %7B%0A            throw new EmptyStackException();%0A        %7D%0A    %7D%0A%0A%7D%0A

add StackWith2Queues